### Problem
Profiling revealed that `usable_space()` calls were consuming 60% of
total execution time for simple SELECT queries, making Limbo
approximately `6x` slower than SQLite for SELECT operations.
The bottleneck was caused by `usable_space()` performing expensive I/O
operations on every call to read `page_size` and `reserved_space` from
the database header, despite `page_size` values being effectively
immutable after database initialization. Only `reserved_space` is
allowed to increase in SQLite.
Evidence: https://share.firefox.dev/44tCUIy
### Solution
Implemented OnceCell-based caching for both page_size and reserved_space
values in the Pager struct:
`page_size: OnceCell<u16>` - Page size is immutable after database
initialization per SQLite specification
`reserved_space: OnceCell<u8>` - Reserved space rarely changes and only
grows, safe to cache
### Performance Impact
Benchmark results: Simple SELECT query time reduced from ~2.89ms to
~1.29ms (~55% improvement)
Closes#1852
Previously, the `jump_if_condition_is_true` flag was not respected. As a
result, for expressions like <`ISNULL`/`NOTNULL`> `OR` <rhs>, the <rhs>
expression was evaluated even when the left-hand side was true, and its
value was incorrectly used as the final result.
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Closes#1846
Previously, the `jump_if_condition_is_true` flag was not respected. As a
result, for expressions like <`ISNULL`/`NOTNULL`> `OR` <rhs>, the <rhs>
expression was evaluated even when the left-hand side was true, and its
value was incorrectly used as the final result.
This PR introduces the ability to introduce latency (e.g thread::sleep)
in every File IO operation. There is a new cli option that configures
the probability of introducing latency. Currently, this probability
defaults to 0, as this change has already detected an infinite loop in
`checkpoint`. To see this bug in action run the following command:
`cargo run -p limbo_sim -- --seed 3961479079923545111 --latency_prob 5`
<img width="918" alt="Pasted Graphic 1" src="https://github.com/user-
attachments/assets/dbf38760-b478-45c2-ac8b-a0ddcf98fd23" />
EDIT: Investigating the bug further, I see that it is returning to the
simulator after the disconnect checkpoint, but I have not yet seen this
test end. Maybe it is just taking too long? Something to look further at
Closes#1770