Commit Graph

476 Commits

Author SHA1 Message Date
Pekka Enberg
b984ddf98f Turso 0.3.0-pre.4 2025-10-22 13:42:52 +03:00
Pekka Enberg
1aba105df4 Merge 'Vector speedup' from Nikita Sivukhin
This PR reduces allocation for vector distance calculation and also use
[simsimd](https://github.com/ashvardanian/SimSIMD) library to execute
cosine/l2 distances for dense vectors.

Reviewed-by: Pere Diaz Bou <pere-altea@homail.com>

Closes #3802
2025-10-22 12:28:43 +03:00
pedrocarlo
8c0b9c6979 add additional fill_bytes method to IO to deterministically generate
random bytes and modify random functions to use them
2025-10-21 14:10:38 -03:00
pedrocarlo
8501bc930a use workspace rand version 2025-10-21 14:10:05 -03:00
Nikita Sivukhin
948bd557cd use simsimd for dense operations 2025-10-21 14:59:01 +04:00
Pekka Enberg
00e6ed82b6 Merge 'tests: Add rowid alias fuzz test case' from Pekka Enberg
This adds a new fuzz test case to verify that any query returns the same
results with and without a rowid alias.

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

Closes #2952
2025-10-17 14:30:18 +03:00
Pekka Enberg
3020966fbd Turso 0.3.0-pre.3 2025-10-17 11:08:36 +03:00
Pekka Enberg
6f71059f07 tests: Add rowid alias fuzz test case
This adds a new fuzz test case to verify that any query returns the same
results with and without a rowid alias.
2025-10-17 10:47:07 +03:00
Jussi Saurio
a1b6eafd03 Merge 'Fix: rolling back tx on Error should set autocommit to true' from Jussi Saurio
Rolling back a transaction on Error should result in
`connection.auto_commit` being set back to true.
Added a regression test for this where a UNIQUE constraint violation
rolls back the transaction and trying to COMMIT will fail.
Currently, our default conflict resolution strategy is ROLLBACK, which
ends the transaction. In SQLite, the default is ABORT, which rolls back
the current statement but allows the transaction to continue.
We should migrate to default ABORT once we support subtransactions.
Closes #3746

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

Closes #3747
2025-10-16 16:55:54 +03:00
Jussi Saurio
4de36d28e6 deps: add tracing to rust bindings 2025-10-16 14:00:26 +03:00
Pekka Enberg
e9c0fdcb4b Turso 0.3.0-pre.2 2025-10-16 11:31:30 +03:00
Pekka Enberg
f8e8ed6228 Merge 'Run SQLite integrity check after stress test run' from Pedro Muniz
Closes #2916

Closes #3730
2025-10-16 10:07:09 +03:00
pedrocarlo
d3bb8beb17 Run SQLite integrity check after stress test run 2025-10-14 13:50:50 -03:00
pedrocarlo
e64aa5d014 add tokio console to write-throughput test 2025-10-14 12:33:36 -03:00
Pekka Enberg
1c9eaa3d95 Merge 'Restrict joins to max 63 tables and allow arbitrary number of table columns' from Jussi Saurio
Closes #2076
Closes #2075

Closes #3705
2025-10-13 18:23:11 +03:00
Jussi Saurio
c2deee1ce5 Merge 'Simulator: ALTER TABLE' from Pedro Muniz
Adds `ALTER TABLE` to the simulator. Currently, there are no properties
that generate `ALTER TABLE`. The query is only generated in
`Property::Query` or in extension queries.
Conditions to generate `ALTER TABLE`:
- In differential testing, do not generate `ALTER COLUMN` as SQLite does
not support it.
- If there is only 1 column, or all columns are present in indexes, do
not generate a `DROP COLUMN` as it would be an error in the database
- if there are no tables, obviously do not generate `ALTER TABLE`
Some fixes:
- handle NULL generation in `GTValue` and `LTValue`, as we now have to
handle nulls due to `ADD COLUMN` adding cols with NULL
- correctly compare NULLs in `binary_compare`

Closes #3650
2025-10-13 14:16:49 +03:00
Jussi Saurio
e055ed9a8d Allow arbitrarily many columns in a table
Use roaring bitmaps because ColumnUsedMask is likely to be
sparsely populated.
2025-10-13 13:30:26 +03:00
Pekka Enberg
fb1042187b Turso 0.3.0-pre.1 2025-10-10 19:25:58 +03:00
pedrocarlo
2cc7947107 define alter table in sql_generation 2025-10-10 11:08:04 -03:00
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