Live data from Hacker News

Go port of SQLite without CGo

gitlab.com

1–10 of 122 posts

Re: Go port of SQLite without CGo

#4

It's a really neat project. I did some simple benchmarks of it and it was between 10% slower to twice as slow. Which depending on your use case isn't that bad! https://datastation.multiprocess.io/blog/2022-05-12-sqlite-i...

What makes it slower?

My guess is that over the years many optimizations have gone into SQLite that would take a lot of effort to catch up to.

Re: Go port of SQLite without CGo

#5

It's a really neat project. I did some simple benchmarks of it and it was between 10% slower to twice as slow. Which depending on your use case isn't that bad! https://datastation.multiprocess.io/blog/2022-05-12-sqlite-i...

What makes it slower?

It’s hard for Go to beat C in a straight benchmark - Go is garbage collected and allocations often have extra overhead due to the memory layout of interfaces.

Re: Go port of SQLite without CGo

#8
If you cross-compile (which everybody using macOS to developer for Linux servers does), it's annoying to introduce SQLite to your project, because immediately the conventional `GOOS= GOARCH= go build` trick stops working. But, in case it's helpful, it's also really easy to set up a full cross-compiling environment, either with Zig or with Filippo's musl-cross:

https://words.filippo.io/easy-windows-and-linux-cross-compil...

I debated doing the pure-Go SQLite thing, but musl-cross worked just fine for me, and kept things simpler.

Re: Go port of SQLite without CGo

#9

What approach is used here? WebAssembly (or something similar)? I see a bunch of huge Go files with architecture names.

It's hard to find actual info on this other than Reddit comments but the author wrote a C to Go compiler and then ran it on the SQLite C code base to get a SQLite Go code base. Which means you don't need CGo to embed SQLite if you use that version.

https://gitlab.com/cznic/ccgo

Edit: Look around the source for "ccgo". Like https://gitlab.com/cznic/sqlite/-/blob/master/doc.go#L202 and look for "ccgo" in the closed issues.

Re: Go port of SQLite without CGo

#10

It's a really neat project. I did some simple benchmarks of it and it was between 10% slower to twice as slow. Which depending on your use case isn't that bad! https://datastation.multiprocess.io/blog/2022-05-12-sqlite-i...

What makes it slower?

Other than what the other responders said, since it uses a C to Go compiler, I'd imagine the Go code that's generated isn't as fast as handwritten Go code could be.
Post reply on HN