Skip to content(if available)orjump to list(if available)

TrailBase: Sub-millisecond open-source application base with Rust, SQLite and V8

randomwebdev

(Disclaimer: I'm PocketBase author)

It is nice to see more backends utilizing SQLite. The benchmarks and the Comparisions section also seem well done.

Just a nitpick - list the versions of the tested platforms.

Based on your benchmarks repo it looks like that the tests were done against PocketBase < v0.23 but note that PocketBase v0.23+ (especially with the Create API rule dry submit removal in v0.24+) has introduced significant changes and performance improvements - ~4x times in high concurrent scenarios in our own benchmarks[0] (if you want to retest it note that the CGO driver is no longer loaded by default and will have to be registered manually; see the example "db_cgo.go" in the PocketBase benchmarks repo or in the "Custom SQLite driver" docs[1]).

[0]: https://github.com/pocketbase/benchmarks

[1]: https://pocketbase.io/docs/go-overview/#custom-sqlite-driver

trailbase

- It is nice to see more backends utilizing SQLite.

Hey thanks for chiming it. Huge fan of PocketBase, has been a major inspiration :applause:. For anyone driving by, certainly a more mature product.

- Based on your benchmarks repo it looks like that the tests were done against PocketBase < v0.23 but note that PocketBase v0.23+ (especially with the Create API rule dry submit removal in v0.24+) has introduced significant changes and performance improvements - ~4x times in high concurrent scenarios in our own benchmarks[0] (if you want to retest it note that the CGO driver is no longer loaded by default and will have to be registered manually; see the example "db_cgo.go" in the PocketBase benchmarks repo or in the "Custom SQLite driver" docs[1]).

You're right. I did run v0.22.21, which simply was current when I ran the benchmarks first. I absolutely will add the information, rerun, and thanks for the pointers. Glad to hear you got such a boost :clap:

trailbase

I'm happy to report that v0.25.0 already w/o CGO driver (fighting it right now) and GOOS=linux CGO_ENABLED=0 GOAMD64=v4 improved about 35% from 61.7s per 100k inserts to about 40s :clap:

I still wanna get the mattn/go-sqlite3 driver to work and it's getting a bit late here for writing coherent text... I'll update the benchmarks ASAP

Guillaume86

Looks interesting, might play with it and the C# client soon, do you plan to build a LINQ provider eventually or keep the APIs similar across client languages?

trailbase

I may plea the fifth, i.e. I'm not sure what this entails but would love to hear more. Also feel free to file a feature request.

Naively, I would argue that being idiomatic in the respective ecosystem is more important than perfect consistency. Only few users will likely use 2 or more languages and probably even then there's a balance to be struck.

Guillaume86

I agree I would generally prefer clients to be idiomatic for the target language but in the case of LINQ providers I understand not doing them since they are quite involved to implement.

You can probably leverage something like https://linq2db.github.io/ and replace some parts of their SQLite provider with HTTP calls to avoid coding most complicated parts. This would be for the raw sql API, for the records API I'm not sure LINQ makes sense since from what I saw in the docs it would be a pretty small subset of LINQ anyway. An easy way to generate the model classes from the DB schema would be nice too (a source generator accessing the schema via some endpoint?).

Edit: it's nice seeing C# getting some love early in a project, I'm used to fallback to js/ts to try the new stuff :)

bigiain

Pretty sure you'll want to consider usage by teams writing in all of Swift, Java, and Javascript as relatively common.

You're likely to encounter people doing "fringe" stuff like transpiling Go or Rust into Wasm, but those folk are all most likely capable of dealing with idiomatic impedance mismatches themselves.

K0IN

what am I missing at the first benchmark? why is there no comparison to pocket base in golang (the language pocket base is written in, and is allowing extensions to be written in)?

trailbase

First and foremost, PocketBase doesn't have an official client in go. There are third-party clients in many languages (more than TB for sure) but at this point I'm not sure how much it makes sense to promote it.

Would it be faster? Maybe, I found that the dart and JS clients didn't reach their theoretical min latency of 3-5ms, so I'm inclined to believe that there's some bottlnecking on the server-side. I'd be very happy to be wrong on this.

From your perspective, would it make sense to just compare the respective dart and JS clients?

twoodfin

If I’m reading this right, the insertion benchmark for TrailBase C# is hitting about 4.4k inserts of relatively small records per second per core.

What’s the bottleneck at that point? That number seems small even when stacked up against much slower examples.

trailbase

The C# insertion benchmark yields roughly 100000k inserts per 5.7s, so it's more like 17.5k inserts per second.

A few observations:

- Both benchmark driver and server are running locally on my laptop, completely saturating the machine.

- I've managed to achieve higher throughput with rust. At least part of it is probably that the client side is lighter on my already saturated machine.

- I've found that I'm getting roughly 3x the performance on a pretty humble 8700G desktop.

- I've found the file-system to have a non-trivial impact.

- The benchmark is only as fast as the bottleneck 50cm in front of the screen managed to make it run. The benchmark driver is here: https://github.com/trailbaseio/trailbase-benchmark/tree/main.... Dotnet is super swift, so I'd be surprised if it couldn't be further optimized (whereas Dart and Node are fairly client-side bottlenecked).

null

[deleted]