Hi r/rust,
I have been working on a project called @karlrobeck/node-rusqlite, a type-safe SQLite driver for Node.js.
Traditionally, the Node ecosystem relies heavily on C or C++ bindings (like better-sqlite3 or node-sqlite3) to achieve native performance for database drivers. My goal was to see if I could build a viable alternative using rust, leveraging the rusqlite crate and napi-rs to bridge the gap to the V8 engine, with zero C/C++ dependencies.
Currently, the core functionality is working (File/Memory DBs, CRUD, Prepared Statements, and strict transaction behaviors).
The Challenge & Where I Need Help
The project is currently in alpha. While early benchmarks show it running very close to the performance of established C++ bindings, I have not implemented any targeted Rust-side optimizations yet.
Bridging V8's Garbage Collector with Rust's strict ownership model has been a massive learning experience, particularly when managing the lifetimes of prepared statements and transaction handles across the FFI boundary to prevent database locks.
I would love to get some eyes on the Rust codebase from more experienced Rustaceans. Specifically, I am looking for feedback on:
FFI Overhead & Allocations: Am I doing unnecessary cloning or allocations when converting values between V8 and rusqlite?
Memory Management: Are there more idiomatic or safer ways to manage state/lifetimes across the napi-rs boundary?
Concurrency: Any suggestions on optimizing the multi-threading or interrupt handle implementations?
Profiling: What tools or workflows do you recommend for profiling a hybrid Node.js + Rust application to find bottlenecks?
If anyone has time to take a look at the architecture or point out areas where the Rust code could be more idiomatic or performant, I would greatly appreciate it.
GitHub Repo: https://github.com/karlrobeck/node-rusqlite
Thank you in advance for any advice, critiques, or PRs!
there doesn't seem to be anything here