mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-04 17:04:18 +01:00
0f9f1787469686fe97782294d19a408913ccd89c
SQLite emits a DecrJumpZero instruction after ResultRow even when there are aggregation functions: ``` sqlite> EXPLAIN SELECT avg(age) FROM users LIMIT 1; addr opcode p1 p2 p3 p4 p5 comment ---- ------------- ---- ---- ---- ------------- -- ------------- 0 Init 0 13 0 0 Start at 13 1 Integer 1 1 0 0 r[1]=1; LIMIT counter 2 Null 0 2 3 0 r[2..3]=NULL 3 OpenRead 0 2 0 10 0 root=2 iDb=0; users 4 Rewind 0 8 0 0 5 Column 0 9 4 0 r[4]= cursor 0 column 9 6 AggStep 0 4 3 avg(1) 1 accum=r[3] step(r[4]) 7 Next 0 5 0 1 8 AggFinal 3 1 0 avg(1) 0 accum=r[3] N=1 9 Copy 3 5 0 0 r[5]=r[3] 10 ResultRow 5 1 0 0 output=r[5] 11 DecrJumpZero 1 12 0 0 if (--r[1])==0 goto 12 12 Halt 0 0 0 0 13 Transaction 0 0 1 0 1 usesStmtJournal=0 14 Goto 0 1 0 0 ``` This does not seem to have any user-visible difference in semantics because we always jump to Halt regardless of the limit. Howwever, to keep generated code consistent with SQLite and avoid special-case paths, let's just emit the instruction.
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 with
io_uring - SQLite compatibility
- SQL dialect support (wip)
- File format support (read-only)
- SQLite C API (wip)
- JavaScript/WebAssembly bindings (wip)
Getting Started
Limbo is currently read-only. You can either use the sqlite3 program to create a database:
$ sqlite3 database.db
SQLite version 3.42.0 2023-05-16 12:36:15
Enter ".help" for usage hints.
sqlite> CREATE TABLE users (id INT PRIMARY KEY, username TEXT);
sqlite> INSERT INTO users VALUES (1, 'alice');
sqlite> INSERT INTO users VALUES (2, 'bob');
or use the testing script to generate one for you:
./testing/gen-database.py
You can then start the Limbo shell with:
$ cargo run database.db
Welcome to Limbo SQL shell!
> SELECT * FROM users LIMIT 1;
|1|Cody|Miller|mhurst@example.org|525.595.7319x21268|33667 Shaw Extension Suite 104|West Robert|VA|45161|`
Developing
Run tests:
cargo test
Test coverage report:
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
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]
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.
Description
Languages
Rust
76.8%
Tcl
6.6%
C
6.4%
Dart
2.4%
Java
2.3%
Other
5.3%
