Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃憠 Replace SQLite with pure Go implementation (need your help!) 馃憟 #408

Closed
muety opened this issue Sep 8, 2022 · 0 comments
Closed
Assignees
Labels

Comments

@muety
Copy link
Owner

muety commented Sep 8, 2022

Wakapi uses SQLite as its default database via mattn/go-sqlite3 and the official GORM driver go-gorm/sqlite. SQLite is implemented in C, so if used in a project, the project must be compiled with CGO_ENABLED=1. That, in turn, requires to have a C-compiler (like gcc or mingw) installed and generally caused a bunch of problems in the past (e.g. when it comes to cross-compilation).

For quite a while, I was looking out for an implementation of SQLite that is in pure Go - so we can get rid of cgo - and eventually found glebarez/go-sqlite, which is based on cznic/sqlite, plus glebarez/sqlite as a compatible GORM driver (relationship among these packages explained here). The base package is actually a transpiled version of the original C code. Note that mattn/go-sqlite3 is still included as a dependency, but apparently only for testing (or so?), so you can well compile without cgo.

The package claims to be fully compatible with the reference implementation and able to act as a drop-in replacement, but comes with a downside in performance (see benchmarks). I'd assume that you wouldn't recognize the worse performance with average Wakapi setups, though.

Since replacing the database implementation is quite a big change, I need your help here! If you're currently self-hosting Wakapi with an SQLite database, it would be super helpful if you could test the new, C-free version as part of your setup. Backup your database (just in case), replace the original Wakapi binary with the one below, keep using Wakapi for a couple of days, see if any errors occur and report them back. Thank you! 馃檹

Compiled locally, doing:

CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags '-w -s' -o wakapi_windows_amd64.exe

Code can be found at the sqlite-go-replacement branch.

@muety muety added help wanted Extra attention is needed technical_task prio c labels Sep 8, 2022
@muety muety self-assigned this Sep 8, 2022
@muety muety pinned this issue Sep 8, 2022
@muety muety changed the title Replace SQLite with pure Go implementation (need your help!) 馃憠 Replace SQLite with pure Go implementation (need your help!) 馃憟 Sep 8, 2022
@muety muety closed this as completed Sep 29, 2022
@YC YC unpinned this issue Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant