modernc.org/sqlite is a pure-Go translation of SQLite, and it is the largest
thing in the binary. Measured with the release flags (-trimpath -ldflags "-s -w -buildid=", linux/amd64, go1.27.3):
| Build | Size | vs today |
|---|---|---|
today: CGO_ENABLED=0 + modernc |
23,085,180 B (22.0 MiB) | — |
cgo + mattn/go-sqlite3, SQLite compiled in |
20,570,752 B (19.6 MiB) | −2.4 MiB (−10.9%) |
cgo + mattn/go-sqlite3 -tags libsqlite3 (system libsqlite3.so.0) |
19,345,008 B (18.4 MiB) | −3.6 MiB (−16.2%) |
SQLite alone is ~4.03 MB of today’s binary (a build with the driver stubbed out
is 19.05 MB); the cgo binding against the system library costs ~0.25 MB. The cgo
driver is also typically several times faster than the modernc translation on
database-heavy paths, which matters for forge/index on a large repository.
Why now: the release tarball and the .deb/.rpm are the main distribution
channel, and a 16% smaller download with faster queries is a straight win. The
cost is that the binary is no longer self-contained: it needs
libsqlite3.so.0 at runtime, which the packages must declare.
Scope
- Replace
modernc.org/sqlitewithgithub.com/mattn/go-sqlite3inforge/index,forge/access,forge/identity,forge/session,forge/pageview,core/lfs, andci/runs. - Rewrite the six DSNs: modernc-only
_pragma=busy_timeout(5000)/_pragma=journal_mode(WAL)/_pragma=foreign_keys(1)become_busy_timeout=5000/_journal_mode=WAL/_foreign_keys=1; the driver name becomessqlite3. -
CGO_ENABLED=1 -tags libsqlite3everywhere: the verify image, the verify workflow steps, the release workflow, and the build instructions. - Cross-compile arm64 in the release image with
gcc-aarch64-linux-gnuandlibsqlite3-dev:arm64; keep both architectures in one job. - Declare the runtime dependency in
packaging/nfpm.yaml:libsqlite3-0for deb,sqlite-libsfor rpm. - Document the new build prerequisites (C compiler,
libsqlite3-dev/sqlite-devel) and the runtime library.
Acceptance criteria
vole workflow run verifypasses, with the test suite running against the system SQLite rather than the amalgamation.- The release build produces both architectures with
libsqlite3.so.0in theirNEEDEDentries, andlibsqlite3-0/sqlite-libsin the package metadata. dist/vole-linux-amd64is materially smaller than the 23.1 MB the current release flags produce.go build -tags libsqlite3 ./cmd/voleand the documented instructions agree.