Commit Graph

457 Commits

Author SHA1 Message Date
pedrocarlo
bb9c8dea4f rework interaction generation to only generate possible queries + do less allocations 2025-10-07 02:36:13 -03:00
Jussi Saurio
90632ad883 Merge 'Improve simulator cli' from bit-aloo
1. Moving manual CLI validation into Clap for safer argument handling.
2. Remove deprecated `with_ascii` flag from `PrettyFields` in logger
initialization.
3. Remove `log` and `env_logger` dependencies in favor of `tracing` from
simulator.

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

Closes #3533
2025-10-05 18:33:55 +03:00
Pekka Enberg
7905841990 Turso 0.2.0 2025-10-03 12:20:42 +03:00
Pekka Enberg
3b1d2535de Turso 0.2.0-pre.15 2025-10-03 11:29:43 +03:00
Pekka Enberg
78e3311c3b Merge 'Sync engine defered sync' from Nikita Sivukhin
This PR makes sync client completely autonomous as now it can defer
initial sync.
This can open possibility to asynchronously create DB in the Turso Cloud
while giving user ability to interact with local DB straight away.

Closes #3531
2025-10-02 17:25:11 +03:00
bit-aloo
889ae2cd78 Remove log and env_logger in favor of tracing
- Deleted `log` and `env_logger` from simulator dependencies
- Migrated remaining `log::error!` and `log::trace!` calls to `tracing` macros
2025-10-02 19:09:09 +05:30
Nikita Sivukhin
91aeadd940 apply create DDL operation with IF NOT EXISTS clause in order to make them idempotent 2025-10-02 15:56:34 +04:00
Pekka Enberg
a44f965a45 Turso 0.2.0-pre.14 2025-10-02 14:29:22 +03:00
Pekka Enberg
4666544ea6 Turso 0.2.0-pre.13 2025-10-01 16:40:53 +03:00
Pekka Enberg
02023ce821 Merge 'core/storage: Switch page cache queue to linked list' from Pekka Enberg
The page cache implementation uses a pre-allocated vector (`entries`)
with fixed capacity, along with a custom hash map and freelist. This
design requires expensive upfront allocation when creating a new
connection, which severely impacted performance in workloads that open
many short-lived connections (e.g., our concurrent write benchmarks that
create a new connection per transaction).
Therefore, replace the pre-allocated vector with an intrusive doubly-
linked list. This eliminates the page cache initialization overhead from
connection establishment, but also reduces memory usage to entries that
are actually used. Furthermore, the approach allows us to grow the page
cache with much less overhead.
The patch improves concurrent write throughput benchmark by 4x for
single-threaded performance.
Before:
```
$ write-throughput --threads 1 --batch-size 100 -i 1000 --mode concurrent
Running write throughput benchmark with 1 threads, 100 batch size, 1000 iterations, mode: Concurrent
Database created at: write_throughput_test.db
Thread 0: 100000 inserts in 3.82s (26173.63 inserts/sec)
```
After:
```
$ write-throughput --threads 1 --batch-size 100 -i 1000 --mode concurrent
Running write throughput benchmark with 1 threads, 100 batch size, 1000 iterations, mode: Concurrent
Database created at: write_throughput_test.db
Thread 0: 100000 inserts in 0.90s (110848.46 inserts/sec)
```

Closes #3456
2025-10-01 16:39:47 +03:00
Pekka Enberg
2b168cf7b0 core/storage: Switch page cache queue to linked list
The page cache implementation uses a pre-allocated vector (`entries`)
with fixed capacity, along with a custom hash map and freelist. This
design requires expensive upfront allocation when creating a new
connection, which severely impacted performance in workloads that open
many short-lived connections (e.g., our concurrent write benchmarks that
create a new connection per transaction).

Therefore, replace the pre-allocated vector with an intrusive
doubly-linked list. This eliminates the page cache initialization
overhead from connection establishment, but also reduces memory usage to
entries that are actually used. Furthermore, the approach allows us to
grow the page cache with much less overhead.

The patch improves concurrent write throughput benchmark by 4x for
single-threaded performance.

Before:

```
$ write-throughput --threads 1 --batch-size 100 -i 1000 --mode concurrent
Running write throughput benchmark with 1 threads, 100 batch size, 1000 iterations, mode: Concurrent
Database created at: write_throughput_test.db
Thread 0: 100000 inserts in 3.82s (26173.63 inserts/sec)
```

After:

```
$ write-throughput --threads 1 --batch-size 100 -i 1000 --mode concurrent
Running write throughput benchmark with 1 threads, 100 batch size, 1000 iterations, mode: Concurrent
Database created at: write_throughput_test.db
Thread 0: 100000 inserts in 0.90s (110848.46 inserts/sec)
```
2025-10-01 14:41:35 +03:00
Jussi Saurio
11bb5f9507 Merge 'Simulator: Concurrent transactions' from Pedro Muniz
Depends on #3272.
First big step towards: #1851
- Add ignore error flag to `Interaction` to ignore parse errors when
needed, and still properly report other errors from intermediate
queries.
- adjusted shrinking to accommodate transaction statements from
different connections and properly remove extensional queries from some
properties
- MVCC: generates `Begin Concurrent` and `Commit` statements that are
interleaved to test snapshot isolation between connection transactions.
- MVCC: if the next interactions are going to contain a DDL statement,
we first commit all transaction and execute the DDL statements serially

Closes #3278
2025-10-01 12:53:32 +03:00
Pekka Enberg
b0d27c90aa Turso 0.2.0-pre.11 2025-09-29 18:11:59 +03:00
pedrocarlo
f2d29ffaaf make transactions truly concurrent with mvcc 2025-09-27 23:52:57 -03:00
Pekka Enberg
2f38d2ef04 Turso 0.2.0-pre.10 2025-09-27 16:52:35 +03:00
Danawan Bimantoro
a58c6a3c0b Merge branch 'main' into main 2025-09-27 11:05:44 +07:00
Pekka Enberg
222ab125c1 Turso 0.2.0-pre.9 2025-09-26 19:00:14 +03:00
Glauber Costa
3dc1dca5a8 use 128-bit hashes for the zset_id
We have used i64 before because that is the size of an integer in
SQLite. However, I believe that for large enough databases, the chances
of collision here are just too high. The effect of a collision is the
database silently returning incorrect data in the materialized view.

So now that everything else is working, we should move to i128.
2025-09-25 22:52:08 -03:00
Glauber Costa
fbc3d0dbc3 Add built-in manual pages for Turso
In the hopes of doing a good job at teaching people what Turso can do,
I am adding built-in manual pages. When the CLI starts, it picks a
feature at random, and tells the user that the feature exists:

```
Turso v0.2.0-pre.8
Enter ".help" for usage hints.
Did you know that Turso supports Change Data Capture? Type .manual cdc to learn more.
This software is ALPHA, only use for development, testing, and experimentation.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database
```

There is a lot we can do to make this feature world class:
- we can automatically compile examples during compile time like
  rust-doc, to make sure examples used in the manuals always work
- we can implement scrolling and navigation
- we can document a lot more features

But for now, this is a start!
2025-09-24 11:29:24 -03:00
danawan
edb6da2d57 pre.8 2025-09-24 15:01:41 +07:00
Pekka Enberg
f72600431b Turso 0.2.0-pre.8 2025-09-24 09:08:34 +03:00
danawan
16b706a8d4 add sqlean fuzzy string distances 2025-09-23 11:49:41 +07:00
Jussi Saurio
04d364d2d0 Merge 'Differential testing fixes' from Pedro Muniz
- Fixed some incorrect code when running interactions in differential
testing. Instead of replacing the state that was used for running the
interaction, I naively just incremented the interaction pointer.
- adjusted the comparison to check returned values without considering
the order of the rows returned
- added differential testing to run in CI
Closes #3235

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

Closes #3255
2025-09-22 22:58:03 +03:00
pedrocarlo
7d1f23dd3a better diffing with similar crate 2025-09-22 15:24:30 -03:00
Pekka Enberg
f6e3beda45 Turso 0.2.0-pre.7 2025-09-22 20:44:08 +03:00
Jussi Saurio
127bc471ff Merge 'Enhancement to Sim Snapshot isolation code' from Pedro Muniz
- Made the code around snapshot isolation more ergonomic with each
connections having its own transaction state. Also when shadowing, we
pass a ShadowTablesMut object that dynamically uses the committed tables
or the connection tables depending on the transaction state.
- added begin concurrent transaction before every property when mvcc is
enabled (this is just so we can have some mvcc code be tested using the
simulator under Begin Concurrent, I have not yet implemented the logic
to have concurrent transactions in the simulator)
- some small enhancements to shrinking
TODOs
- have proper logic to have concurrent transactions without WriteWrite
conflicts. This means when generating the plans we need to make sure
that we do not generate rows that will conflict with rows in other
transactions. This is slightly more powerful than what we do in the
fuzzer, as we just have `WriteWriteConflict` as an acceptable error
there. By baking this `NoConflict` approach to the simulator, we can
continuously test the what does not trigger a WriteWriteConflict and
snapshot isolation.

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

Closes #3226
2025-09-22 12:48:36 +03:00
Pekka Enberg
26f90257a6 Turso 0.2.0-pre.6 2025-09-22 11:44:21 +03:00
Pekka Enberg
f4b0fb17f7 Turso 0.2.0-pre.5 2025-09-22 11:34:22 +03:00
Pekka Enberg
fbad158213 Turso 0.2.0-pre.4 2025-09-22 09:15:55 +03:00
Pekka Enberg
6280cfc59d Merge branch 'main' into sync-improvements 2025-09-22 07:35:39 +03:00
Avinash Sajjanshetty
0597ea722a Add encryption throughput test 2025-09-20 21:56:58 +05:30
pedrocarlo
c3cdb0e0fd add begin concurrent before each statement with mvcc 2025-09-20 11:52:15 -03:00
Nikita Sivukhin
7049f3ddae fix clock implementation for OPFS IO 2025-09-19 13:21:00 +04:00
Nikita Sivukhin
66de28d84b wip 2025-09-19 13:19:30 +04:00
Avinash Sajjanshetty
10137ffaa4 run whopper with encryption if arg is passed 2025-09-17 21:58:27 +05:30
pedrocarlo
3c91ae206b move as many dependencies as possible to workspace to avoid multiple versions of the same dependency 2025-09-15 17:19:36 -03:00
Jussi Saurio
26c0d72c25 perf/thrpt: add tracing 2025-09-15 14:25:18 +03:00
pedrocarlo
cc48fa233b add perf/throughput/rusqlite to workspace 2025-09-14 18:29:03 -03:00
pedrocarlo
01a99f84a6 add perf/throughput/turso to workspace 2025-09-14 16:19:34 -03:00
Avinash Sajjanshetty
1536f65f07 move test helper run_query to common module 2025-09-13 11:00:39 +05:30
Avinash Sajjanshetty
3f72de3623 Add checksum module 2025-09-13 11:00:37 +05:30
Pekka Enberg
5df05e05f8 Turso 0.2.0-pre.3 2025-09-12 18:40:06 +03:00
Pekka Enberg
2651b597c6 Turso 0.2.0-pre.2 2025-09-12 17:38:30 +03:00
Jussi Saurio
4f7ffa0e62 Commit uncommitted whopper lockfile 2025-09-12 08:43:59 +03:00
Pekka Enberg
7d8a1a0d5f Merge 'whopper: A new DST with concurrency' from Pekka Enberg
Our simulator is currently limited to concurrency of one. This
introduces a much less sophisticated DST with focus on finding
concurrency bugs.

Closes #2985
2025-09-11 18:42:45 +03:00
Jussi Saurio
7ac18a6952 Merge 'Remove some traces in super hot paths in btree' from Preston Thorpe
Particularly we were tracing `ImmutableRecord` / `BTreeKey` which would
then trace the bytes of records. These are super super hot paths and I
think we can probably remove even more to under debug assertions so we
dont eat those atomics/branches all the time.
This PR also introduces the `tracing_release` feature, which turns all
`trace!` and `debug!` macro invocations to noops at compile time, and
makes that feature available for all bindings.
it also removes the unused `lru` dependency, and cleans up the makefile
a bit

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

Closes #2995
2025-09-11 13:33:25 +03:00
Pekka Enberg
ae3c1fc2a6 Turso 0.2.0-pre.1 2025-09-11 11:44:42 +03:00
Pekka Enberg
89d1c9a421 whopper: Switch to mmap2 crate to fix Windows build 2025-09-11 08:35:18 +03:00
Pekka Enberg
a9694c87b1 whopper: A new DST with concurrency
This is a new deterministic simulator for Turso that focuses on finding
concurrency bugs.

You can run whopper with:

```console
penberg@vonneumann turso % SEED=1234 ./whopper/bin/run
   Compiling turso_whopper v0.1.5-pre.3 (/Users/penberg/src/tursodatabase/turso/whopper)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.22s
seed = 1234
       .             I/U/D/C
       .             44/19/11/2
       .             68/33/21/2
       |             104/51/29/3
       |             121/69/41/3
      ╱|╲            150/84/51/3
     ╱╲|╱╲           184/97/59/3
    ╱╲╱|╲╱╲          199/105/64/4
   ╱╲╱╲|╱╲╱╲         206/115/69/5
  ╱╲╱╲╱|╲╱╲╱╲        234/138/82/6
 ╱╲╱╲╱╲|╱╲╱╲╱╲       269/164/91/7
```
2025-09-11 08:35:18 +03:00
PThorpe92
f117b2c966 Remove unused lru dependency 2025-09-10 09:55:04 -04:00