Commit Graph

130 Commits

Author SHA1 Message Date
Mazdak Farrokhzad 8e3af49f64 Reuse buffers in ServerMessage<BsatnFormat> (#2911)
# Description of Changes

Fixes https://github.com/clockworklabs/SpacetimeDB/issues/2824.

Defines a global pool `BsatnRowListBuilderPool` which reclaims the
buffers of a `ServerMessage<BsatnFormat>` and which is then used when
building new `ServerMessage<BsatnFormat>`s.

Notes:
1. The new pool `BsatnRowListBuilderPool` reports the same kind of
metrics to prometheus as `PagePool` does.
2. `BsatnRowListBuilder` now works in terms of `BytesMut`.
3. The trait method `fn to_bsatn_extend` is redefined to be capable of
dealing with `BytesMut` as well as `Vec<u8>`.
4. A trait `ConsumeEachBuffer` is defined from
`ServerMessage<BsatnFormat>` and down to extract buffers.
`<ServerMessage<_> as ConsumeEachBuffer>::consume_each_buffer(...)` is
then called in `messages::serialize(...)` just after bsatn-encoding the
entire message and before any compression is done. This is the place
where the pool reclaims buffers.

# Benchmarks

Benchmark numbers vs. master using `cargo bench --bench subscription --
--baseline subs` on i7-7700K, 64GB RAM:

```
footprint-scan          time:   [21.607 ms 21.873 ms 22.187 ms]
                        change: [-62.090% -61.438% -60.787%] (p = 0.00 < 0.05)
                        Performance has improved.

full-scan               time:   [22.185 ms 22.245 ms 22.324 ms]
                        change: [-36.884% -36.497% -36.166%] (p = 0.00 < 0.05)
                        Performance has improved.
```

The improvements in `footprint-scan` are mostly thanks to
https://github.com/clockworklabs/SpacetimeDB/pull/2918, but 7 ms of the
improvements here are thanks to the pool. The improvements to
`full-scan` should be only thanks to the pool.

# API and ABI breaking changes

None

# Expected complexity level and risk

2?

# Testing

- Tests for `Pool<T>` also apply to `BsatnRowListBuilderPool`.
2025-12-18 23:02:36 +00:00
Mazdak Farrokhzad ed2a18cff7 Bump hashbrown, foldhash; Fix some compile errors in master (#3722)
# Description of Changes

There were mentions of `hashbrown` in the repo that did not go through
`spacetimedb_data_structures::map`.
This caused compile errors on master when running certain tests locally.
These have been replaced with the proper imports.

The PR also bump hashbrown to 0.16.1 and foldhash to 0.2.0.

# API and ABI breaking changes

None

# Expected complexity level and risk

2

# Testing

Covered by existing tests.
2025-11-25 12:17:24 +00:00
joshua-spacetime f5d3bcd1be Add view handling to query engine and planner (#3578)
# Description of Changes

This patch does the following:

1. Expands views as part of query planning. Views are always assumed to
be materialized by the query planner, however a view's backing table may
have private columns such as the `sender` column. The query planner
needs to filter by this column in order to select the rows pertaining to
a particular caller.
2. Plumbs `AuthCtx` through the query optimizer. This is needed in order
to implement (1).
3. Adds a new operator for views to the query engine that drops a view's
private columns

# API and ABI breaking changes

None

# Expected complexity level and risk

2.5

# Testing

- [x] SQL http tests
- [ ] Subscription tests
- [ ] One off query tests
2025-11-05 19:19:26 +00:00
Noa 619b8ce021 Bump Rust to 1.90 (#3397)
# Description of Changes

Necessary for pulling in rolldown.

# API and ABI breaking changes

None

# Expected complexity level and risk

1, with the caveat that this updates the Rust version and therefore
touches all the code.

# Testing

- [ ] Just the automated testing
2025-10-09 20:41:25 +00:00
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
Zeke Foppa f6f0909ea4 Update all licenses (#3002)
# Description of Changes

We recently merged several repos together. This PR clarifies the license
terms for several subdirectories, as well as the relationship between
the licenses.

The licenses in our subdirectories have become symbolic links to
licenses in our toplevel `licenses` directory. For any particular
subdirectory's license file in the diff, you can click `... -> View
file` and then click on the text that says "Symbolic Link" on that page.
This will take you to the license file that it links to.

I have also updated the `tools/upgrade-version` script to update the
change date in the new `licenses/BSL.txt` file.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

None. Only changes to license files.

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-08-12 18:20:58 +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 0c3635188d Auto-migrate: Allow adding new variants at the tail (#2874) 2025-06-27 17:29:31 +00:00
Viktor Szépe f6da9e1f5f Fix typos (#2812)
Signed-off-by: Viktor Szépe <viktor@szepe.net>
2025-06-04 16:33:32 +00:00
Tyler Cloutier c30cdea2af Fixed compile errors and warnings on Windows (#2646) 2025-05-21 22:32:29 +00:00
Mazdak Farrokhzad 373e47db39 PagePool::{default -> new_for_test} + temporary hack for IN_MEMORY_CONFIG / test_index_scans (#2707) 2025-05-12 13:15:07 +00:00
joshua-spacetime dc3dd68ebc Do not double compress transaction update messages (#2668) 2025-04-30 16:22:30 +00:00
Mazdak Farrokhzad eb589728c6 Allocate pages using a mult-tenant lock-free pool (#2587) 2025-04-28 17:35:19 +00:00
Noa 483a9488e2 Update rand (#2568) 2025-04-11 17:39:41 +00:00
joshua-spacetime ec30c0b048 Add rls to the subscription api (#2546) 2025-04-04 21:12:39 +00:00
Jeffrey Dallatezza 64aef29d3c Add endpoints for heap profiling (#2517)
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-03-31 18:12:31 +00:00
joshua-spacetime 01c391f8a9 Add sql support for :sender parameter (#2483) 2025-03-21 17:53:34 +00:00
Jeffrey Dallatezza a4a2925f12 Use jemalloc in standalone and add stats. (#2470) 2025-03-20 19:00:06 +00:00
Mario Montoya f9f38543c8 Add readmes to all implementation crates specifying that they do no offer stable interfaces (#2320) 2025-03-06 19:50:17 +00:00
Jeffrey Dallatezza bf82614d9c Send delete updates for unsubscribes (#2271) 2025-02-18 17:46:16 +00:00
Mazdak Farrokhzad b50b6841f1 Add direct indices to datastore (#2221) 2025-02-07 01:06:38 +00:00
joshua-spacetime 75ab91d36d Handle optimization and execution errors on initial subscription (#2213) 2025-02-06 19:14:44 +00:00
Mazdak Farrokhzad 6630a90ee1 Switch DeleteTable impl to one based on FixedBitSet (#2183) 2025-01-29 17:15:17 +00:00
Noa 293aebaef9 Bump to Rust 1.84 (#2001) 2025-01-28 23:11:29 +00:00
joshua-spacetime 3798f468a6 query engine integration (#2074) 2025-01-11 00:01:24 +00:00
Mazdak Farrokhzad d4f03b74b9 datastore: insert via BSATN instead of via PV (#2069) 2025-01-07 21:36:02 +00:00
Jeffrey Dallatezza e9e287b8aa Server-side implementation of incremental subscription changes (#2030) 2025-01-02 18:41:57 +00:00
Mazdak Farrokhzad 6f22261859 Fix subscription benchmarks by fixing create_table_for_test_with_the_works (#2027) 2024-12-05 13:12:09 +00:00
james gilles c657b4f088 Rip useless names out of RawDef (#1918) 2024-11-20 21:02:00 +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 cb9e0176e6 Fix benches for ia_loop, circles (#1922) 2024-11-05 14:50:31 +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
Tyler Cloutier 83fc5c33d4 The banishment of Address (#1880)
Co-authored-by: Jeffrey Dallatezza <jeffreydallatezza@gmail.com>
2024-10-23 01:56:20 +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
Mazdak Farrokhzad 1e35fe681f Add gzip + none compression algos and let SDK pick compression (#1802) 2024-10-09 16:46:41 +00:00
Mazdak Farrokhzad 1ac741aa6b Generic and optimized WebSocket API (#1761)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-09-30 21:57:00 +00:00
joshua-spacetime a15f60bfbc feat: Integrate type checking into current query code (#1756) 2024-09-30 21:27:56 +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
james gilles 2be42156b2 Allow converting new ModuleDef to old TableSchema (#1630) 2024-08-29 18:17:29 +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