4 ms·
Decided to run this with NodeJS (on Linux) for mandatory Web Scale: 100k inserts using `better-sqlite3` (difference: it does use prepared statements), all sing
by klabb3 4y ago
Decided to run this with NodeJS (on Linux) for mandatory Web Scale:
100k inserts using `better-sqlite3` (difference: it does use prepared statements), all single-threaded with the same pragmas.
- 8.6k inserts/s with `uuid` and `Date.toUTCString()`
- 12.0k inserts/s with faking uuid and date (generated unique strings)
...So a large amount of time was spend in uuid generation and current date.
EDIT: I mixed up the two numbers above. Simple strings is of course faster than syscall+date format+entropy. Fixed now.
It's fair to say that although Rust is slightly more Web Scale, this benchmark simply measures the excellent performance of SQLite.
- sroussey 4y agoTry again with bun. It uses a baked-in SQLite silicate to better-sqlite3. https://bun.sh https://bun.sh
- klabb3 4y agoWeird, I just ran some benchmarks with bun a few days ago for my own purposes, and I concluded that their marketing slogan was bs and Node was faster. However, I did it again with this example and Bun is indeed significantly faster - 15.1k inserts/s with `uuid` and `Date.toUTCString()` - 20k inserts/s with faking uuid and date (generated unique strings) Bun is now scientifically at the Rust level of Web Scale, which is pretty crazy. I wonder how they do that, because it's still just v8 under the hood? Mayhaps their sqlite driver is faster.
- Jarred 4y agoWhat benchmark did you run where Node outperformed Bun? Happy to take a look. There are still "obvious" things we need to fix, like our EventEmitter implementation is currently around 3x slower than Node due to C++ <> JS callback overhead and several functions in node:crypto are still using JS-only polyfills intended for web browsers (instead of BoringSSL/OpenSSL).
- klabb3 4y ago> What benchmark did you run where Node outperformed Bun? It was a very similar SQLite bench but I may have done something wrong. > Happy to take a look. That’s ok but let me bait and switch you for this dead socket leak issue: https://github.com/oven-sh/bun/issues/1397 https://github.com/oven-sh/bun/issues/1397 In general, I’ve found that tons of projects suffer leaks. People don’t care about leaks :( (or alternative the tooling for discovering them kinda sucks)
- promiseofbeans 4y agoOne of their tricks is that Bun doesn't use Chrome's V8. Instead, they use Safari's JavascriptCore, which tends to be faster[citation needed].
- re-thc 4y agoThat's an important point but not likely the bulk of the issue (vs Node). Deno that uses V8 is also faster than Node. Node has a lot of other issues before we get to the Javascript engine part even.
- deleted 4y ago[deleted]
- sroussey 4y agoNot V8… it’s Apple’s JavaScript Core.
- infogulch 4y agoFrom my experience years ago a tight loop { bind() step() } in a transaction can run fast.
- mscdex 4y agoEven with node.js, it's possible to be faster and/or use less memory than better-sqlite3. For example, here is an opinionated sqlite addon I wrote that shows just that (while executing queries asynchronously): https://github.com/mscdex/esqlite https://github.com/mscdex/esqlite