Commit Graph

54 Commits

Author SHA1 Message Date
Kim Altintop b445620f03 Fix module hotswapping for connected clients (#3159)
The `Clone` impl for `ClientConnection` would create an independent
instance that could not observe module hotswapping. This would result in
methods called on a replaced `ModuleHost` to fail, because that host
exited already.

Fix by reading the `ModuleHost` from the watch channel directly, instead
of maintaining a redundant copy.

Also fix `watch_module_host` to properly mark the current module host as
seen.

# Expected complexity level and risk

2

# Testing

- [x] test suite passes
- [x] ran @bfops repro script
2025-08-13 18:36:06 +00:00
Noa 742303ca49 Bump rust-toolchain to rust 1.88 (#2749)
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2025-07-15 17:39:41 +00:00
Tyler Cloutier 20b087c248 Split datastore into its own crate (#2933) 2025-07-12 21:41:00 +00:00
Mazdak Farrokhzad eb589728c6 Allocate pages using a mult-tenant lock-free pool (#2587) 2025-04-28 17:35:19 +00:00
Mazdak Farrokhzad d4f03b74b9 datastore: insert via BSATN instead of via PV (#2069) 2025-01-07 21:36:02 +00:00
Ingvar Stepanyan a7a1d36535 Run and test benchmarks against C# as well (#1965)
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2024-11-15 17:27:11 +00:00
Noa f136670420 Directory structure impl (#1879)
Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
2024-11-12 04:24:43 +00:00
Ingvar Stepanyan 15b3e0647d NFC: Remove unused fsync param in benchmarks (#1981) 2024-11-11 18:38:14 +00:00
Ingvar Stepanyan 6d712b4b0d Simplify benchmarking wrappers (#1951) 2024-11-06 17:21:56 +00:00
Mario Montoya a6a6c4f08f Put ExecutionContext inside the Tx context (#1876)
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2024-10-29 16:24:06 +00:00
Mazdak Farrokhzad 263511e15b Redefine Address as U128 + Identity and Hash as U256 (#1616)
Co-authored-by: James Gilles <jameshgilles@gmail.com>
2024-10-18 20:00:21 +00:00
james gilles c32f297c47 Update TableSchema & system tables to resemble ABI V9 (#1697) 2024-09-25 20:03:22 +00:00
Ingvar Stepanyan 2cccac4e14 C# module benchmarks (#1679) 2024-09-06 18:08:14 +00:00
Mazdak Farrokhzad 1ca9b1a933 [WASM ABI 1.0] Change ColId from u32 to u16 (#1597) 2024-08-19 17:56:28 +00:00
james gilles 45b2ceee9a Move schemas to schema crate, rename Def to RawDefV8 (#1498) 2024-07-24 17:38:30 +00:00
james gilles f81f2a7492 Move db module from spacetimedb_sats to spacetimedb_lib (#1479) 2024-07-17 20:59:44 +00:00
Noa 10b151b999 Protobufectomy: server (#1077)
Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Jeremie Pelletier <jeremiep@gmail.com>
2024-07-12 18:02:18 +00:00
Mario Montoya 80b64669eb Adding benchmark for deserialize json & product value (#1035) 2024-07-10 14:31:49 +00:00
Mario Montoya 814dd5b738 Add small 'realistic' workload benchmark integration test (#714) 2024-06-13 18:28:35 +00:00
Mazdak Farrokhzad d6815ebf9c Shrink AV and AT to 24 & 16 bytes respectively, and also friends. (#1047) 2024-04-13 16:51:18 +00:00
Kim Altintop 47048559b4 core: Integrate new commitlog + durability (#926)
This patch attempts to integrate the new commitlog with the minimum
changes.

Most of the diff comes from deletions of the legacy log and the need to
adjust tests due to the requirement for a tokio runtime when a durable
database is used in tests.

The "meat" of the patch are the `RelationalDB` constructors,
`RelationalDB::commit_tx`, and the replay logic in
`locking_tx_datastore`.

While `DataKey` is gone, there is still some redundant data being passed
around, which will be addressed in the follow-up patch.
2024-04-11 22:46:31 +00:00
Mazdak Farrokhzad 344861f290 use nohasher_hash and ahash instead of siphash13 (#1040)
* use nohasher_hash and ahash instead of siphash13

* re-export types in spacetimedb_data_structures::map
2024-04-05 17:30:51 +00:00
Phoebe Goldman ba8a8d93c3 BFLATN -> BSATN fast-path for fixed-length rows (#1005)
* Implement (but do not use) a fast path for BFLATN -> BSATN conversion

* fmt and clippy

* `u16` offset rather than `usize`

* Address Joshua's review

* Define methods on `RowRef` and `RelValue` which use the new serializer

* Comment in `align_to` about div-by-zero

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>

* Add benchmark comparing BFLATN -> BSATN with and without the fast path

* Add benchmark on `u64_u64_u32`, which has less interior padding than `u32_u64_u64`

* Remove `to_len` from `to_bsatn_extend`

It turns out to be slower than just eating the `realloc`s.

* Remove unused `to_bsatn_slice`

I thought I would need it, but it ended up not being useful.

* Expand comment with example; `Box<[...]>` to reduce memory footprint

* Comments from Mazdak's review

---------

Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2024-03-25 19:46:10 +00:00
Mazdak Farrokhzad 5601c18c52 perf: don't clone QueryExpr (#981)
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2024-03-15 19:55:35 +00:00
Mazdak Farrokhzad f2a75f7f33 take AV by ref in iter_by_col_eq (#925) 2024-03-05 10:46:54 +00:00
james gilles a0a18ddd57 Rename types in benchmarks (#803)
* Rename types in benchmarks, modify benches run in action

* Fix lints
2024-02-23 20:30:59 +00:00
Mazdak Farrokhzad 913801e22a - Make RelValue into a cow-like structure. (#869)
- Move it and friends from sats to vm.
- MemTable now stores a Vec<PV>.
- Other related improvements.

Co-authored-by: Phoebe Goldman <phoebe@goldman-tribe.org>
2024-02-21 20:07:39 +00:00
Noa b4f75d272f Bump Rust to 1.76.0 (#811)
* Bump Rust to 1.76.0

* Fix new clippy lints

* Use rust-toolchain in smoketests
2024-02-09 19:40:03 +00:00
james gilles fa93200397 1_000_000 insert + update benchmarks (#764)
* Add 1_000_000 insert benches, disabled by default.

* memory architecture fix
2024-02-07 18:24:08 +00:00
Zeke Foppa 510c9aba5a pt1 (#785) 2024-02-05 15:45:14 +00:00
Shubham Mishra e152784c3b feat: subscription to use read type tx (#685)
* made MutTxId -> MutTx

* adopt using ass. type for tx

* fmt

* read tx in datastore

lint

test

lint

made MutTxId -> MutTx

adopt using ass. type for tx

fmt

added more methods to TxId

fix test

Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Signed-off-by: Shubham Mishra <shivam828787@gmail.com>

comments on Test

Co-authored-by: Phoebe Goldman <phoebe@clockworklabs.io>
Signed-off-by: Shubham Mishra <shivam828787@gmail.com>

fmt

typo

* fix imports

* clippy

* read tx in datastore

lint

test

lint

added read tx in subs

fmt

fix iters

* comments

* comments

* fix schema_for_table

* fmt

* merge queue helped

* moved all_read_query anaylyzing to vm

* lint

* added StateView trait

* lint

* fix tests for read-tx-in-subs (#695)

Intention of this PR is to keep diff of main PR smaller - feat: subscription to use read type tx #685 by separating trivial unit test related changes from main logic.
naming changes begin_tx() -> begin_mut_tx() and begin_read_tx() -> begin_tx()

* rollback_tx -> release_tx

* Compiler should work with Write Tx

* execute sql with mut tx

* fix result len

* compiler to work with write tx (#716)

* Compiler should work with Write Tx

* merge queue helped
2024-01-21 19:59:26 +00:00
james gilles 26263cbd5f Rebase callgrind benchmark work (#619) 2024-01-10 18:53:51 +00:00
Ingvar Stepanyan ab63654dab Support arbitrary RHS in C# Query (#586) 2023-12-05 17:28:46 +00:00
Mario Montoya 4ef1bd5296 Refactoring bootstrapping and adding full support for constraints & multi-column indexes (#596)
* Refactoring bootstrapping and adding full support for constraints & multi-column indexes

* Removed deleted code and add some comments

* Add comment for Constraints

* Update crates/core/src/db/datastore/locking_tx_datastore/mod.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Update crates/core/src/db/datastore/locking_tx_datastore/mod.rs

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>

* Addressing some PR comments & remove cloning

* Adding details for when fail to decode rows in replay

* Apply Kim's fix for replay bug

* Addressing some PR comments

* Merge

* Fix conflicts

* Fix conflicts

* Fix test

* Fix generation of code for csharp & typescript, now it generate FilterBy for all columns

* Fix for index generation

* Fixing C# index generation

* Merge

* Fix compilation on csharp bindings

---------

Signed-off-by: Mario Montoya <mamcx@elmalabarista.com>
Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-12-04 12:04:38 -05:00
Mario Montoya b3ccc13dab Refactoring IDs for system objects (#439)
* Refactoring IDs for system objects

* fixup

* Fix stray constraints text on refactor

* Fix conflict

* Merge

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2023-11-15 10:21:20 -05:00
Mario Montoya f12a238237 Moving object defs to SATS (#460)
* Moving object defs to SATS

* move ColumnIndexAttribute to primitives, nix path attr

* revert unnecessary reformating

* ProductValue: don't take ColId
ProductValues can be more than rows and can be nested

* simplify sats::db::def wrt. Constraints + impl ser/de

* cargo fmt

---------

Co-authored-by: Mazdak Farrokhzad <twingoow@gmail.com>
2023-11-13 12:21:56 +00:00
joshua-spacetime fce9477e81 perf(463): Add metric for the number of rows fetched from the database (#467)
Closes #463.

This metric is maintained by the datastore iterator.
It is written to the metric store when the iterator is dropped.
Only committed rows are counted.
2023-10-25 16:00:11 -07:00
joshua-spacetime 23b2e6c713 perf(461): Record metrics for rows [inserted|deleted] on commit (#462)
Closes #456.
Closes #461.

Define an execution context for database operations.
Store the database id in RelationalDB.
Record metrics for rows [inserted|deleted] on commit.
2023-10-25 15:28:26 -07:00
Noa bc54b735b5 Update/upgrade dependencies (#266)
* Update and dedup some deps

* Upgrade dependencies
2023-10-25 01:19:29 +01:00
Mazdak Farrokhzad cba518d90e Use newtypes ColId, TableId, IndexId, SequenceId everywhere (*) (#408)
* Use newtypes ColId, TableId, IndexId, SequenceId everywhere (*)

* Addressing some PR comments

---------

Co-authored-by: Mario Alejandro Montoya Cortés <mamcx@elmalabarista.com>
2023-10-19 11:18:50 -05:00
james gilles a952b19e5b Improve benchmark result reporting (#357)
* Add script to summarize benchmark results

* Mess with github actions benchmark script

* Formatting fixes

* Comment

* Bring back commit comments, upload to DO Spaces

* Remove cache

We now have servers for benchmarks outside of GH infrastructure and
downloading cache takes way more time than its worth it

* base and head refs are not needed anymore

* Run benchmarks only on master

* Test a branch build

* Fix branch becnhmarks path

* test

* Run only on master again

---------

Signed-off-by: Piotr Sarnacki <drogus@gmail.com>
Co-authored-by: Piotr Sarnacki <drogus@gmail.com>
2023-10-16 22:52:27 +02:00
joshua-spacetime ca532c9609 test(414): multi-column index scan (#415)
Closes #414.

Adds a test for calling iter_by_col_eq with multiple columns.
Ensures the index is scanned if an applicable multi-column index is present.
To write this test, iter_by_col_eq was updated to take multiple columns.
2023-10-12 22:04:58 +00:00
james gilles cd88c21237 Put out benchmark fires (#404)
* Reverts benchmarks portion of "Bench for SQL scan / where (#370)"
This partially reverts commit 05956d6.

* Get benchmarks runner to remember what it has installed, hopefully

* Fix build error
2023-10-12 14:14:46 +01:00
Ingvar Stepanyan 7edff4a213 Compile benchmarks in separate folder (#411) 2023-10-11 19:21:41 +01:00
Ingvar Stepanyan ad366a740b Benchmark modules in release mode (#396) 2023-10-10 18:25:32 +01:00
Mazdak Farrokhzad ff69ec4a10 flatten BuiltinValue into AlgebraicValue (#389) 2023-10-09 18:58:52 +02:00
Mazdak Farrokhzad a45c30c3d9 sats: misc refactoring (#382)
- more conversions
- prepare for getting rid of BuiltinValue & BuiltinType
- prepare for slim slices
2023-10-08 02:05:25 +02:00
Mario Montoya 05956d6817 Bench for SQL scan / where (#370)
* Bench for sql scan

* Add SQL..WHERE bench

* Factour out the request for table schema, and remove some duplicate logic
2023-10-05 20:06:41 -05:00
james gilles 010c7e3c1e Wrangle benchmarks (#289)
Refactor benchmarks framework to allow direct comparison of spacetime modules, the spacetime datastore not through a module, and sqlite.
2023-09-29 23:12:12 +00:00
joshua-spacetime e72b8f3d1b perf(datastore): disable fsync mode by default (#221) 2023-08-23 18:22:53 -07:00