July 17th, 2024

Show HN: SQLite Transaction Benchmarking Tool

The "sqlite-bench" GitHub project tests SQLite transaction behavior. It provides code, compilation guidelines, and running instructions. To protect SSD, run benchmarks on in-memory filesystem first. Docker image available.

Read original articleLink Icon
Show HN: SQLite Transaction Benchmarking Tool

The GitHub project "sqlite-bench" is designed for testing SQLite transaction behavior. It offers code for a blog post and guidelines on compiling and executing the benchmark tool. To compile, use `cargo build --release`, and for running, employ `cargo run --release -- --help` to view options. To safeguard your SSD, it's advised to initially run the benchmark on an in-memory filesystem. Instructions for setting up an in-memory filesystem on MacOS and Linux are included. Additionally, a multiplatform Docker image for this project can be accessed at the provided GitHub link.

Link Icon 2 comments
By @leononame - 4 months
Thanks for the interesting article. Lots of things seem to happen in SQLite land at the moment and I appreciate that the SQLite team documents their quirks so openly, it gives great confidence.

Since I don't know where else to ask, maybe this is a good place: How do async wrappers around SQLite (e.g. for node or python) work? SQLite only uses synchronous I/O if I'm not mistaken. Is it just a pretend async function with only synchronous code?

And, as a follow-up: If I have a server with say 100 incoming connections that will all read from the database, I've got 100 readers. No problem in WAL mode. However, I still could get congested by file I/O, right? Because every time a reader is waiting for data from disk, I can't execute the application code of another connection in a different thread since execution is blocked on my current thread. Is there any benefit to having a thread pool with a limit of more than $NUM_CPU readers?

And one more: Would you recommend actually pooling connections or just opening/closing the database for each request as needed? Could keeping a file handle open prevent SQLite from checkpointing under certain conditions?