You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Switch over to modernc.org/sqlite as the SQLite driver #7882
The use of github.com/mattn/go-sqlite3 requires CGO which prevents us from cross-compile more release archives, and making the release process very cumbersome and easily outdated.
Before the switch over, we need to do a sanity test on SQLite file compatibility, i.e. create the SQLite file with github.com/mattn/go-sqlite3 and continue use with modernc.org/sqlite.
A wise choice indeed. Thanks for switching to the native Go package. I've been using it as well for a time, and I can't really tell the difference — except, of course, for making things far more portable across platforms!
The benchmarks, however, clearly show that it's hard to beat a C library with native Go:
The benchmark was written by modernc, of course, so they cheated a bit. Apparently, their native Go code can beat CGo quite clearly in a scenario with multiple simultaneous reads — and when launching tons of goroutines to handle the load. I'm assuming that the issue here comes from limitations in how CGo needs to protect all those memory accesses for each goroutine (since the calls are made to unprotected C). By contrast, Go's native goroutines, running only native Go, are much more efficiently implemented — and this reflects quite positively on those benchmarks.
I would therefore assume that someone running Gogs with SQLite in a scenario with hundreds or thousands of users, all reading/writing to large repositories with lots of files (and commits, etc...), will see a substantial improvement in their overall performance. By contrast, small repositories with few files and just a handful of users might get worse performance out of Gogs.
That said, I can't really speak about my own case — I use MariaDB as the backend 🤣
Activity
GwynethLlewelyn commentedon Jul 1, 2025
A wise choice indeed. Thanks for switching to the native Go package. I've been using it as well for a time, and I can't really tell the difference — except, of course, for making things far more portable across platforms!
The benchmarks, however, clearly show that it's hard to beat a C library with native Go:
https://pkg.go.dev/modernc.org/sqlite-bench#section-readme
The benchmark was written by
modernc, of course, so they cheated a bit. Apparently, their native Go code can beat CGo quite clearly in a scenario with multiple simultaneous reads — and when launching tons of goroutines to handle the load. I'm assuming that the issue here comes from limitations in how CGo needs to protect all those memory accesses for each goroutine (since the calls are made to unprotected C). By contrast, Go's native goroutines, running only native Go, are much more efficiently implemented — and this reflects quite positively on those benchmarks.I would therefore assume that someone running Gogs with SQLite in a scenario with hundreds or thousands of users, all reading/writing to large repositories with lots of files (and commits, etc...), will see a substantial improvement in their overall performance. By contrast, small repositories with few files and just a handful of users might get worse performance out of Gogs.
That said, I can't really speak about my own case — I use MariaDB as the backend 🤣