Commit Graph

4071 Commits

Author SHA1 Message Date
pedrocarlo
2ec58b0264 state machine for sort 2025-08-09 21:50:18 -03:00
pedrocarlo
c91c22a6a8 state machine for next 2025-08-09 21:50:18 -03:00
pedrocarlo
2ffc5ee423 SorterChunk read and write should return completions 2025-08-09 21:50:18 -03:00
PThorpe92
718114f5da Keep free api consistent with try_alloc, size instead of pages 2025-08-08 11:50:16 -04:00
PThorpe92
213d589dd1 Apply review suggestions, remove FreeEntry 2025-08-08 11:07:29 -04:00
PThorpe92
84ffed709a Round up allocation for wal frame arena to next page multiple of 64 2025-08-08 10:55:29 -04:00
PThorpe92
d182b836ef Remove basic test for buffer pool to avoid race conditions in CI 2025-08-08 10:55:29 -04:00
PThorpe92
faf248df03 Add more docs and comments for TempBufferCache 2025-08-08 10:55:28 -04:00
PThorpe92
34d90d5acb Remove Clone impl for Buffer and PageContent to make any copying of page data explicit 2025-08-08 10:55:28 -04:00
PThorpe92
d41377454c Fix test asserting for arena size instead of page size 2025-08-08 10:55:28 -04:00
PThorpe92
d7e4ba21f8 Add explanation for using 3mb limit 2025-08-08 10:55:28 -04:00
PThorpe92
ff7d9fe961 Add basic test for buffer pool initialization and basic use 2025-08-08 10:55:28 -04:00
PThorpe92
66964fd8d2 Add documentation and comments to new buffer pool, add get_frame api 2025-08-08 10:55:28 -04:00
PThorpe92
d94e252ef9 Actually pre-register two arenas with the ring 2025-08-08 10:55:28 -04:00
PThorpe92
f9df267f42 Increase test arena size and fix import 2025-08-08 10:55:28 -04:00
PThorpe92
39d230a899 Add bitmap for tracking pages in arena 2025-08-08 10:55:27 -04:00
PThorpe92
0ffba81216 Make register buffer io trait return the buf index 2025-08-08 10:55:27 -04:00
PThorpe92
3cff47e490 Fix btree test to properly initialize pool 2025-08-08 10:55:27 -04:00
PThorpe92
fd09fe1237 Adjust io_uring to register two arenas, one for frames and the other for db pages 2025-08-08 10:55:27 -04:00
PThorpe92
cc75bc448e Move TLC buffer cache to io/mod 2025-08-08 10:55:27 -04:00
PThorpe92
9d1ca1c8ca Add ReadFixed/WriteFixed opcodes for buffers from registered arena 2025-08-08 10:55:27 -04:00
PThorpe92
dffa47b048 Use temp buffer for wal header 2025-08-08 10:55:27 -04:00
PThorpe92
7ea52a3f89 Fix changing page size and initialization for buffer pool 2025-08-08 10:55:26 -04:00
PThorpe92
0884fec799 Use parent buffer pool for ephemeral pager and wal 2025-08-08 10:55:26 -04:00
PThorpe92
5750b1229c Setup and initialize pool properly 2025-08-08 10:55:26 -04:00
PThorpe92
4ffb273b53 Adjust IO to use new buffer pool and buffer API 2025-08-08 10:55:26 -04:00
PThorpe92
27113885a9 Update sorter to use new buffer api 2025-08-08 10:55:26 -04:00
PThorpe92
a02f527c06 Add fast path for pwritev on other IO backends 2025-08-08 10:55:25 -04:00
PThorpe92
39bccc2357 Update Buffer type in io module to adjust to new pool 2025-08-08 10:55:25 -04:00
PThorpe92
d38cd6360a Create new arena backed buffer pool 2025-08-08 10:55:25 -04:00
Preston Thorpe
d3e6172516 Merge 'global allocator should not be set for library, only for executables' from Pedro Muniz
We should be allocator-agnostic. It is pretty limiting for us to force a
user to use a particular allocator. This is specially restricting for
`no_std` in the future.

Reviewed-by: bit-aloo (@Shourya742)
Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2481
2025-08-08 09:45:35 -04:00
Jussi Saurio
2fbe33d200 Merge 'translate: return parse errors for unsupported features instead of silently ignoring' from Jussi Saurio
Closes #1510

Closes #2505
2025-08-08 15:56:13 +03:00
Jussi Saurio
cca2f6c947 Merge 'Evaluate WHERE conditions after LEFT JOIN' from Piotr Rżysko
This fix ensures that `WHERE` conditions are emitted after the `LEFT
JOIN` match flag is set, so rows from the right table are properly
filtered, even when they are `NULL` due to the outer join.
Previously, the query below would return rows where `products.price` was
`NULL`:
```sql
SELECT users.id, price
FROM users
LEFT JOIN products ON users.id = products.id
WHERE products.price IS NOT NULL;
```

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #2501
2025-08-08 15:54:17 +03:00
Jussi Saurio
21dc2d0161 translate: return parse errors for unsupported features instead of silently ignoring 2025-08-08 11:39:30 +03:00
Jussi Saurio
7fd63d8a5d btree: cache usable_space in the btreecursor constructor 2025-08-08 10:32:18 +03:00
Jussi Saurio
15c429b673 btree: remove completely unused ParseRecordState 2025-08-08 10:08:59 +03:00
Pekka Enberg
0f9d0cf519 Merge branch 'main' into 2025-08-07-add-query-only-pragma 2025-08-08 07:41:38 +03:00
Piotr Rzysko
375b9047e2 Evaluate WHERE conditions after LEFT JOIN
Previously, the query from the added test would not filter out rows
where `products.price` was NULL.
2025-08-08 06:26:30 +02:00
Piotr Rzysko
92ba25e44d Extract loop emitting conditions into a method
No functional changes — this is just preparation for reusing this code
and avoiding polluting future commits with trivial refactoring.
2025-08-08 06:21:08 +02:00
bit-aloo
c7f7ae32e3 review fixes 2025-08-08 08:43:15 +05:30
Preston Thorpe
850ee8fe62 Merge 'bench/insert: fix expected return value from pragma' from Jussi Saurio
CI did not fail when this panicked :]

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2489
2025-08-07 21:34:13 -04:00
Preston Thorpe
7a793b818d Merge 'perf: a few small insert optimizations' from Jussi Saurio
1. We spend a lot of time in `cell_get_raw_region` in the balancing
routine, and especially calling `contents.page_type()` there a lot, so
extract a version that can take some precomputed arguments so those
don't have to be redundantly computed multiple times for successive
calls where those values are going to be the same
2. Avoid calling `self.usable_space()` in a loop in
`insert_into_page()`.
3. Avoid accessing `pages_in_frames` lock if we're not going to modify
it
main improvement is to the "insert 100 rows" bench which ends up doing
balancing a lot:
```
Insert rows in batches/limbo_insert_1_rows
                        time:   [22.856 µs 24.342 µs 27.496 µs]
                        change: [-3.3579% +15.495% +67.671%] (p = 0.62 > 0.05)
                        No change in performance detected.

Benchmarking Insert rows in batches/limbo_insert_10_rows: Collecting 100 samples in estim
Insert rows in batches/limbo_insert_10_rows
                        time:   [32.196 µs 32.604 µs 32.981 µs]
                        change: [+1.3253% +2.9177% +4.5863%] (p = 0.00 < 0.05)
                        Performance has regressed.

Insert rows in batches/limbo_insert_100_rows
                        time:   [89.425 µs 92.105 µs 96.304 µs]
                        change: [-18.317% -13.605% -9.1022%] (p = 0.00 < 0.05)
                        Performance has improved.
```

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2483
2025-08-07 21:33:30 -04:00
Preston Thorpe
6b266e7e84 Merge 'Direct schema mutation – add instruction' from Levy A.
<img width="960" height="205" alt="image" src="https://github.com/user-
attachments/assets/f60a2133-dfe4-4411-9a7c-7283eb073875" />
<img width="944" height="504" alt="image" src="https://github.com/user-
attachments/assets/9383c8e2-4d8d-40b9-8ace-825ca3cf8682" />
```
`ALTER TABLE _ ADD COLUMN _`/limbo_add_column/
                        time:   [2.1199 ms 2.1921 ms 2.2756 ms]
                        change: [-85.983% -85.416% -84.716%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 13 outliers among 100 measurements (13.00%)
  6 (6.00%) high mild
  7 (7.00%) high severe
`ALTER TABLE _ ADD COLUMN _`/sqlite_add_column/
                        time:   [10.358 ms 10.404 ms 10.469 ms]
                        change: [-6.2566% -2.3515% +0.2046%] (p = 0.21 > 0.05)
                        No change in performance detected.
Found 14 outliers among 100 measurements (14.00%)
  2 (2.00%) high mild
  12 (12.00%) high severe
  ```

Reviewed-by: Preston Thorpe <preston@turso.tech>

Closes #2482
2025-08-07 21:31:49 -04:00
PThorpe92
bcadcb2014 Remove RefCell from copy_to method in io trait 2025-08-07 17:07:53 -04:00
PThorpe92
98f4e5cd2d Add comment/TODO about method we use to copy the db file 2025-08-07 16:27:08 -04:00
PThorpe92
e32d04ea97 Use ephemeral PlatformIO for clone method to support memory io 2025-08-07 16:27:08 -04:00
PThorpe92
039fe22405 Add copy_to to io::File trait to support copying DB files 2025-08-07 16:27:02 -04:00
Preston Thorpe
e23637b6ad Merge 'only allow multiples of 64 for performance in arena bitmap' from Preston Thorpe
Trying to support this is unnecessary and just adds branches and bit ops
when we could just round the allocation up or down

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #2497
2025-08-07 14:25:11 -04:00
bit-aloo
aaeec4d4f3 Implement PRAGMA query_only logic 2025-08-07 23:49:07 +05:30
bit-aloo
2cf7f66a02 Enforce query_only in write operations 2025-08-07 23:46:00 +05:30