Files
SpacetimeDB/crates/sats/Cargo.toml
Mazdak Farrokhzad ae15508dee Identifiers: Refactor + Improve type-safety & performance (#4177)
# Description of Changes

The goal of this PR is to:
- Make it easy to switch our backing implementation of identifiers, as
seen in the commit changing to `LeanString`.
- Improve type safety of our identifiers by having every identifier
start with `RawIdentifier` and then `Identifier` is just a wrapper with
validation on construction. `TableName` and `ReducerName` are then just
wrappers around `Identifier`.
- Reduce allocation in `InstanceEnv` by using the now clone-on-write
O(1) + SSO optimized `Identifier`.
- Reduce allocations in the query engine as a consequence of improving
`RawIdentifier` and `Identifier`.
- Have `&'static str` strings be further optimized by avoiding to
allocate even for long ones. This is supported by `impl From<&'static
str> for RawIdentifier` as well as switching to `LeanString`.

The PR results in a roughly 2k TPS improvement over master for WASM +
hash indices. This should also help V8, as this is VM-agnostic.

# API and ABI breaking changes

None

# Expected complexity level and risk

3? Mostly just small changes in many places, but in a sea of small
changes, mistakes can happen.

# Testing

Covered by existing tests.
2026-02-04 20:54:56 +00:00

83 lines
2.7 KiB
TOML

[package]
name = "spacetimedb-sats"
version.workspace = true
edition.workspace = true
license-file = "LICENSE"
description = "Spacetime Algebraic Type Notation"
rust-version.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
serde = ["dep:serde"]
# Allows using `Arbitrary` impls defined in this crate.
proptest = ["dep:proptest", "dep:proptest-derive"]
# Allows using additional test-only methods defined in this crate.
test = ["proptest"]
# Impls `Serialize` and `Deserialize` for `blake3::Hash`.
# Used by `spacetimedb_table`,
# which serializes and deserializes Blake3 hashes during snapshotting.
blake3 = ["dep:blake3"]
# Impls `Serialize`, `Deserialize` and `SpacetimeType` for `ByteString`.
# Used by `spacetimedb_client_api_messages`,
# which encodes rows and reducer arguments as `ByteString`s containing JSON.
# Feature-gated because `bytestring` depends on `serde`,
# which we don't want in `spacetimedb_bindings`.
bytestring = ["dep:bytestring"]
metrics_impls = ["dep:spacetimedb-metrics"]
# Gated to avoid including this in `spacetimedb_bindings`.
memory-usage = ["dep:spacetimedb-memory-usage", "spacetimedb-primitives/memory-usage"]
[dependencies]
spacetimedb-bindings-macro.workspace = true
spacetimedb-primitives.workspace = true
spacetimedb-memory-usage = { workspace = true, optional = true, default-features = false, features = [
"ethnum",
"decorum",
] }
spacetimedb-metrics = { workspace = true, optional = true }
anyhow.workspace = true
arrayvec.workspace = true
bitflags.workspace = true
bytes.workspace = true
bytemuck.workspace = true
bytestring = { workspace = true, optional = true }
chrono = { workspace = true, features = ["alloc"] }
decorum.workspace = true
derive_more.workspace = true
enum-as-inner.workspace = true
ethnum.workspace = true
hex.workspace = true
itertools.workspace = true
lean_string.workspace = true
# For the 'proptest' feature.
proptest = { workspace = true, optional = true }
proptest-derive = { workspace = true, optional = true }
sha3.workspace = true
second-stack.workspace = true
serde = { workspace = true, optional = true }
smallvec.workspace = true
thiserror.workspace = true
uuid.workspace = true
[target.'cfg(not(all(target_arch = "wasm32", target_os = "unknown")))'.dependencies]
uuid = { workspace = true, features = ["v4", "v7"] }
rand = { workspace = true, features = ["std"] }
# For the `blake3` feature.
blake3 = { workspace = true, optional = true }
[dev-dependencies]
ahash.workspace = true
bytes.workspace = true
rand.workspace = true
# Also as dev-dependencies for use in _this_ crate's tests.
proptest.workspace = true
proptest-derive.workspace = true
serde_json.workspace = true
serde.workspace = true
[lints]
workspace = true