libsql-js
libsql-js copied to clipboard
Improve performance
We are still a bit behind better-sqlite3. For example, there's more overhead in get():
penberg@vonneumann libsql-js % node perf/perf-libsql.js
cpu: Apple M1
runtime: node v18.19.0 (arm64-darwin)
benchmark time (avg) (min … max) p75 p99 p999
------------------------------------------------- -----------------------------
• Statement
------------------------------------------------- -----------------------------
get(1) 1'969 ns/iter (1'911 ns … 2'539 ns) 1'970 ns 2'424 ns 2'539 ns
summary for Statement
get(1)
penberg@vonneumann libsql-js % node perf/perf-better-sqlite3.js
cpu: Apple M1
runtime: node v18.19.0 (arm64-darwin)
benchmark time (avg) (min … max) p75 p99 p999
------------------------------------------------- -----------------------------
• Statement
------------------------------------------------- -----------------------------
get(1) 587 ns/iter (555 ns … 1'122 ns) 584 ns 944 ns 1'122 ns
The assumption that a lot of this is memory memory allocations and copies as values are passed between the C, Rust, and JavaScirpt layers. We also suspect that Neon Bindings may be less efficient than better-sqlite3 is which seems to hook into the V8 APIs directly.
Let's improve the benchmarks, profile, and fix performance to be on-par with better-sqlite3.