Manually vendored in some changes from [lemon- rs](https://github.com/gwenn/lemon-rs), including a merged change from @krishvishal and [an unmerged PR ](https://github.com/gwenn/lemon- rs/pull/81) from user ignatz that boxes Limit. I also boxed `OneSelect` because it also improved perf in the benchmarks. 40-50% more throughput with these changes to our existing admittedly simple benchmarks. Added a new more complex prepare benchmark that includes group by and having as well, which is also 42% faster with the new code. **Runs on my local machine:** ``` main: limbo/Prepare statement: 'SELECT 1' time: [1.2902 µs 1.2927 µs 1.2958 µs] thrpt: [771.73 Kelem/s 773.56 Kelem/s 775.07 Kelem/s] change: time: [+0.2770% +0.6013% +0.9243%] (p = 0.00 < 0.05) thrpt: [-0.9158% -0.5977% -0.2762%] limbo/Prepare statement: 'SELECT * FROM users LIMIT 1' time: [2.4885 µs 2.4927 µs 2.4971 µs] thrpt: [400.47 Kelem/s 401.18 Kelem/s 401.84 Kelem/s] change: time: [+1.2859% +1.6970% +2.0993%] (p = 0.00 < 0.05) thrpt: [-2.0561% -1.6687% -1.2696%] limbo/Prepare statement: 'SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1)... time: [5.6867 µs 5.6994 µs 5.7164 µs] thrpt: [174.93 Kelem/s 175.46 Kelem/s 175.85 Kelem/s] change: time: [+16.921% +17.332% +17.765%] (p = 0.00 < 0.05) thrpt: [-15.085% -14.772% -14.472%] this branch: limbo/Prepare statement: 'SELECT 1' time: [861.48 ns 862.60 ns 863.79 ns] thrpt: [1.1577 Melem/s 1.1593 Melem/s 1.1608 Melem/s] change: time: [-33.293% -33.042% -32.754%] (p = 0.00 < 0.05) thrpt: [+48.709% +49.347% +49.909%] Performance has improved. limbo/Prepare statement: 'SELECT * FROM users LIMIT 1' time: [1.6080 µs 1.6106 µs 1.6140 µs] thrpt: [619.58 Kelem/s 620.87 Kelem/s 621.88 Kelem/s] change: time: [-35.838% -35.611% -35.380%] (p = 0.00 < 0.05) thrpt: [+54.750% +55.305% +55.857%] Performance has improved. Benchmarking limbo/Prepare statement: 'SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1)...: Collecting 100 samples in estimated 5.0125 s (1. limbo/Prepare statement: 'SELECT first_name, count(1) FROM users GROUP BY first_name HAVING count(1)... time: [4.0161 µs 4.0301 µs 4.0473 µs] thrpt: [247.08 Kelem/s 248.13 Kelem/s 249.00 Kelem/s] change: time: [-29.791% -29.596% -29.399%] (p = 0.00 < 0.05) thrpt: [+41.642% +42.038% +42.431%] Performance has improved. ``` **Runs in CI:** ``` most recent commit on main: limbo/Prepare statement: 'SELECT 1' time: [2.7085 µs 2.7113 µs 2.7153 µs] thrpt: [368.28 Kelem/s 368.83 Kelem/s 369.21 Kelem/s] limbo/Prepare statement: 'SELECT * FROM users LIMIT 1' time: [4.8688 µs 4.8713 µs 4.8741 µs] thrpt: [205.17 Kelem/s 205.29 Kelem/s 205.39 Kelem/s] this branch: limbo/Prepare statement: 'SELECT 1' time: [1.9278 µs 1.9329 µs 1.9405 µs] thrpt: [515.33 Kelem/s 517.35 Kelem/s 518.73 Kelem/s] limbo/Prepare statement: 'SELECT * FROM users LIMIT 1' time: [3.5708 µs 3.5 µs 3.5794 µs] thrpt: [279.38 Kelem/s 279.75 Kelem/s 280.05 Kelem/s] ``` **Discussion:** Generally I think we should probably just, philosophically, hard fork this vendored code and start making whatever modifications we want to it... thoughts? Also I guess there's a way to add a co-authored by XXX to these commits so that they don't show up under my name only, because I didn't write most of it. Closes #620
Limbo
Limbo is a work-in-progress, in-process OLTP database management system, compatible with SQLite.
Features
- In-process OLTP database engine library
- Asynchronous I/O support on Linux with
io_uring - SQLite compatibility (status)
- SQL dialect support
- File format support
- SQLite C API
- JavaScript/WebAssembly bindings (wip)
- Support for Linux, macOS, and Windows
Getting Started
CLI
Install limbo with:
curl --proto '=https' --tlsv1.2 -LsSf \
https://github.com/tursodatabase/limbo/releases/latest/download/limbo-installer.sh | sh
Then use the SQL shell to create and query a database:
$ limbo database.db
Limbo v0.0.6
Enter ".help" for usage hints.
limbo> CREATE TABLE users (id INT PRIMARY KEY, username TEXT);
limbo> INSERT INTO users VALUES (1, 'alice');
limbo> INSERT INTO users VALUES (2, 'bob');
limbo> SELECT * FROM users;
1|alice
2|bob
JavaScript (wip)
Installation:
npm i limbo-wasm
Example usage:
import { Database } from 'limbo-wasm';
const db = new Database('sqlite.db');
const stmt = db.prepare('SELECT * FROM users');
const users = stmt.all();
console.log(users);
Python (wip)
pip install pylimbo
Example usage:
import limbo
con = limbo.connect("sqlite.db")
cur = con.cursor()
res = cur.execute("SELECT * FROM users")
print(res.fetchone())
Developing
Build and run limbo cli:
cargo run --package limbo --bin limbo database.db
Run tests:
cargo test
Test coverage report:
cargo tarpaulin -o html
Note
Generation of coverage report requires tarpaulin binary to be installed. You can install it with
cargo install cargo-tarpaulin
Tip
If coverage fails with "Test failed during run" error and all of the tests passed it might be the result of tarpaulin bug. You can temporarily set dynamic libraries linking manually as a workaround, e.g. for linux
LD_LIBRARY_PATH="$(rustc --print=target-libdir)" cargo tarpaulin -o html.
Run benchmarks:
cargo bench
Run benchmarks and generate flamegraphs:
echo -1 | sudo tee /proc/sys/kernel/perf_event_paranoid
cargo bench --bench benchmark -- --profile-time=5
FAQ
How is Limbo different from libSQL?
Limbo is a research project to build a SQLite compatible in-process database in Rust with native async support. The libSQL project, on the other hand, is an open source, open contribution fork of SQLite, with focus on production features such as replication, backups, encryption, and so on. There is no hard dependency between the two projects. Of course, if Limbo becomes widely successful, we might consider merging with libSQL, but that is something that will be decided in the future.
Publications
- Pekka Enberg, Sasu Tarkoma, Jon Crowcroft Ashwin Rao (2024). Serverless Runtime / Database Co-Design With Asynchronous I/O. In EdgeSys ‘24. [PDF]
- Pekka Enberg, Sasu Tarkoma, and Ashwin Rao (2023). Towards Database and Serverless Runtime Co-Design. In CoNEXT-SW ’23. [PDF] [Slides]
Contributing
We'd love to have you contribute to Limbo! Check out the contribution guide to get started.
License
This project is licensed under the MIT license.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Limbo by you, shall be licensed as MIT, without any additional terms or conditions.
