GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Integrate tiered storage by kim · Pull Request #6305 · clockworklabs/SpacetimeDB

Integrate tiered storage #6305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
joshua-spacetime merged 62 commits into master from kim/tiered-storage-integration
Nov 18, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

Integrate tiered storage #6305

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
9be226c
Integrate tiered storage
kim Oct 15, 2026
24b0761
Restore direct page storage for resident tables
joshua-spacetime Oct 15, 2026
5ee10f5
Deduplicate resident commit and page recycling paths
joshua-spacetime Oct 16, 2026
cfc1d6f
Remove added resident storage tests from review diff
joshua-spacetime Oct 16, 2026
d6fee45
Drop macOS-only size assertion adjustments
joshua-spacetime Oct 16, 2026
1617d36
Fix CI formatting and resident table size assertion
joshua-spacetime Oct 16, 2026
3c4b6d5
Explain resident storage optimization rationale and constraints
joshua-spacetime Oct 16, 2026
1ab80d6
Adjust for base changes
kim Oct 16, 2026
bc7c423
Require the page slot lock to be held when acquiring a frame lock, and
kim Oct 19, 2026
431f97c
Use a Mutex for the page slot
kim Oct 19, 2026
962bf63
Guard against races in page eviction
kim Oct 19, 2026
7df10bb
Put page index back into free_page_slots if allocation fails.
kim Oct 19, 2026
bcf9338
Count only resident blob bytes for memory accounting
kim Oct 19, 2026
1bbadf6
Reuse registry frames when reserving already-pinned blobs
kim Oct 19, 2026
4771321
Auto-evict pages under budget pressure
kim Oct 20, 2026
40fa178
Now that ReservedBlob contains an Arc<Frame>, we can use ptr_eq to
kim Oct 20, 2026
0eba036
Use arrays instead of slices for object key / hashes
kim Oct 19, 2026
8cab37a
Properly roll back row insertion when blob writing fails
kim Oct 22, 2026
087e7e9
Make index deletion atomic
kim Oct 22, 2026
412040f
Make make_index_non_unique atomic
kim Oct 22, 2026
7b7df7f
Make constraint manipulations atomic
kim Oct 22, 2026
014d633
Avoid going through `RowRef` when collecting row pointers.
kim Oct 22, 2026
3da2f51
Roll back migrations when view refresh fails
kim Oct 22, 2026
675fdc6
Make `delete_equal_row` atomic (used during replay)
kim Oct 22, 2026
2674cb9
Clean up rebase artifacts
kim Oct 22, 2026
7ad2413
Undo physical inserts when pinning of the resulting `RowRef`'s
kim Oct 22, 2026
9275bb8
Restore the tx index when dropping the committed index fails
kim Oct 22, 2026
9ecd02c
Make `Table::clear` atomic
kim Oct 22, 2026
65af4cc
Generalize temporary row handling, and apply
kim Oct 22, 2026
4278c22
Fix two more rollback safety issues.
kim Oct 23, 2026
1c798dc
Make a number of operations infallible again by passing `PinnedRow`
kim Oct 23, 2026
75b20f2
Reuse pinned rows during datastore cleanup and update results (#6423)
joshua-spacetime Nov 2, 2026
191f767
Use pinned rows to make datastore mutations failure-safe (#6434)
joshua-spacetime Nov 2, 2026
6b008a9
Preserve committed index state during schema rollback (#6440)
joshua-spacetime Nov 2, 2026
ad37517
WIP: local object store
kim Oct 19, 2026
cd26881
Add system table for cache policies and enable local disk paging (#6443)
joshua-spacetime Nov 6, 2026
7e033ff
Local tier budget accounting + eviction
kim Nov 5, 2026
6ffa5ea
Add blanket impl ObjectStore for Arc<T>
kim Nov 9, 2026
5ea9962
Use tx state blob set for view refresh
kim Nov 9, 2026
1a04a5d
Evict to low watermark
kim Nov 10, 2026
2464d8e
Add TODO about double-deserialization of pages
kim Nov 10, 2026
7739c21
Test that failure to remove the local object preserves the permit
kim Nov 10, 2026
19536fb
Tiered storage metrics (#6550)
joshua-spacetime Nov 11, 2026
b057329
Merge 'kim/local-disk-eviction' into 'kim/tiered-storage-io'
joshua-spacetime Nov 11, 2026
68d0caf
Merge 'kim/tiered-storage-io' into 'kim/tiered-storage-integration'
joshua-spacetime Nov 11, 2026
dc54b21
Ensure all objects are installed into local storage when restoring fr…
kim Nov 12, 2026
4b04803
Support `NoRequirement` cache policy migrations (#6578)
joshua-spacetime Nov 13, 2026
9a35a8b
Reclaim local tier objects (#6581)
kim Nov 16, 2026
6786826
Use database-wide eviction instead of per-table (#6586)
joshua-spacetime Nov 16, 2026
2f1d418
Separate namespaces for pages and blobs in disk storage (#6599)
kim Nov 16, 2026
c660db7
Database-wide eviction for (some) reads (#6607)
joshua-spacetime Nov 16, 2026
aec51d4
Acquire db.lock before opening the table cache
joshua-spacetime Nov 16, 2026
2b39df2
More tiered storage metrics (#6609)
joshua-spacetime Nov 17, 2026
0564389
Merge branch 'master' into kim/tiered-storage-integration
joshua-spacetime Nov 17, 2026
8ef39a0
Use bytes::Bytes instead of Arc<[u8]>
joshua-spacetime Nov 17, 2026
3e19dbd
Rollback failed view materializations
joshua-spacetime Nov 17, 2026
ef7b056
Implement MemoryUsage for TieredDatabaseStorage
kim Nov 17, 2026
e5b14af
Add module for tiered storage smoketests (#6580)
kim Nov 17, 2026
1474e62
Database-wide eviction for snapshot creation and commitlog replay
joshua-spacetime Nov 17, 2026
021a1c8
Return transaction commit errors to clients instead of panicking
joshua-spacetime Nov 17, 2026
3a52982
Surface resident memory budget failures and limits to clients
joshua-spacetime Nov 17, 2026
009a889
Exempt connection and publishing metadata from resident memory limits
joshua-spacetime Nov 17, 2026
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

24 changes: 24 additions & 0 deletions 24 Cargo.lock
Show comments
View file
Open in desktop

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

3 changes: 3 additions & 0 deletions 3 Cargo.toml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ members = [
"crates/sats",
"crates/schema",
"crates/smoketests",
"crates/tiered-storage",
"sdks/csharp/test-harness~",
"sdks/rust",
"sdks/unreal",
Expand Down Expand Up @@ -199,6 +200,7 @@ spacetimedb-subscription = { path = "crates/subscription", version = "=2.16.0" }
spacetimedb-sql-parser = { path = "crates/sql-parser", version = "=2.16.0" }
spacetimedb-table = { path = "crates/table", version = "=2.16.0" }
spacetimedb-test-datastore = { path = "crates/test-datastore", version = "=2.16.0" }
spacetimedb-tiered-storage = { path = "crates/tiered-storage", version = "=2.16.0" }

# Prevent `ahash` from pulling in `getrandom` by disabling default features.
# Modules use `getrandom02` and we need to prevent an incompatible version
Expand All @@ -221,6 +223,7 @@ blake3 = "1.5.1"
brotli = { version = "3.5", default-features = false, features = ["std"] }
bytemuck = { version = "1.16.2", features = ["must_cast"] }
bytes = "1.10.1"
bytesize = "2.0.1"
bytestring = { version = "1.2.0", features = ["serde"] }
cargo_metadata = "0.17.0"
chrono = { version = "0.4.24", default-features = false }
Expand Down
11 changes: 6 additions & 5 deletions 11 crates/bench/benches/special.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use spacetimedb_lib::sats::{self, bsatn};
use spacetimedb_lib::{bsatn::ToBsatn as _, ProductValue};
use spacetimedb_schema::schema::TableSchema;
use spacetimedb_schema::table_name::TableName;
use spacetimedb_table::page_pool::PagePool;
use spacetimedb_table::tiered::{EvictionPolicy, PageManager};
use spacetimedb_testing::modules::{Csharp, ModuleLanguage, Rust};
use std::sync::Arc;
use std::sync::OnceLock;
Expand Down Expand Up @@ -141,24 +141,25 @@ fn serialize_benchmarks<
let mut table = spacetimedb_table::table::Table::new(
Arc::new(table_schema),
spacetimedb_table::indexes::SquashedOffset::COMMITTED_STATE,
PageManager::new_for_test().into(),
EvictionPolicy::NeverEvict,
);
let pool = PagePool::new_for_test();
let mut blob_store = spacetimedb_table::blob_store::HashMapBlobStore::default();
let blob_store = spacetimedb_table::tiered::BlobSet::new_for_test();

let ptrs = data_pv
.elements
.iter()
.map(|row| {
table
.insert(&pool, &mut blob_store, row.as_product().unwrap())
.insert(&blob_store, row.as_product().unwrap())
.unwrap()
.1
.pointer()
})
.collect::<Vec<_>>();
let refs = ptrs
.into_iter()
.map(|ptr| table.get_row_ref(&blob_store, ptr).unwrap())
.map(|ptr| table.get_row_ref(&blob_store, ptr).unwrap().unwrap())
.collect::<Vec<_>>();
group.bench_function(format!("bflatn_to_bsatn_slow_path/count={count}"), |b| {
b.iter(|| {
Expand Down
15 changes: 9 additions & 6 deletions 15 crates/bench/src/spacetime_raw.rs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use crate::{
schemas::{table_name, BenchTable, IndexStrategy},
ResultBench,
};
use spacetimedb::db::relational_db::{tests_utils::TestDB, RelationalDB};
use spacetimedb::{
db::relational_db::{tests_utils::TestDB, RelationalDB},
error::DatastoreError,
};
use spacetimedb_datastore::execution_context::Workload;
use spacetimedb_primitives::{ColId, IndexId, TableId};
use spacetimedb_sats::{bsatn, AlgebraicValue};
Expand Down Expand Up @@ -120,8 +123,8 @@ impl BenchDatabase for SpacetimeRaw {
.db
.iter_mut(tx, *table_id)?
.take(row_count as usize)
.map(|row| row.to_product_value())
.collect::<Vec<_>>();
.map(|row| row.map(|r| r.to_product_value()))
.collect::<Result<Vec<_>, DatastoreError>>()?;

assert_eq!(rows.len(), row_count as usize, "not enough rows found for update_bulk!");
let mut scratch = Vec::new();
Expand All @@ -133,7 +136,7 @@ impl BenchDatabase for SpacetimeRaw {
.db
.iter_by_col_eq_mut(tx, *table_id, 0, &row.elements[0])?
.next()
.expect("failed to find row during update!")
.expect("failed to find row during update!")?
.pointer();

assert_eq!(
Expand All @@ -160,7 +163,7 @@ impl BenchDatabase for SpacetimeRaw {
fn iterate(&mut self, table_id: &Self::TableId) -> ResultBench<()> {
self.db.with_auto_commit(Workload::Internal, |tx| {
for row in self.db.iter_mut(tx, *table_id)? {
black_box(row);
black_box(row?);
}
Ok(())
})
Expand All @@ -174,7 +177,7 @@ impl BenchDatabase for SpacetimeRaw {
) -> ResultBench<()> {
self.db.with_auto_commit(Workload::Internal, |tx| {
for row in self.db.iter_by_col_eq_mut(tx, *table_id, col_id, &value)? {
black_box(row);
black_box(row?);
}
Ok(())
})
Expand Down
11 changes: 9 additions & 2 deletions 11 crates/bindings-csharp/Codegen.Tests/fixtures/server/Lib.cs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,15 @@ public static void Init(ReducerContext ctx)
}
}

[SpacetimeDB.Table(Accessor = "MultiTable1", Public = true)]
[SpacetimeDB.Table(Accessor = "MultiTable2")]
[SpacetimeDB.Table(
Accessor = "MultiTable1",
Public = true,
CachePolicy = SpacetimeDB.TableCachePolicy.RequiredOnDisk
)]
[SpacetimeDB.Table(
Accessor = "MultiTable2",
CachePolicy = SpacetimeDB.TableCachePolicy.NoRequirement
)]
public partial struct MultiTableRow
{
[SpacetimeDB.Index.BTree(Table = "MultiTable1")]
Expand Down
6 changes: 6 additions & 0 deletions 6 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2238,6 +2238,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar

public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null;

public static SpacetimeDB.TableCachePolicy CachePolicy =>
SpacetimeDB.TableCachePolicy.RequiredOnDisk;

/// <summary>
/// Returns the number of rows in this table.
///
Expand Down Expand Up @@ -2374,6 +2377,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar

public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null;

public static SpacetimeDB.TableCachePolicy CachePolicy =>
SpacetimeDB.TableCachePolicy.NoRequirement;

/// <summary>
/// Returns the number of rows in this table.
///
Expand Down
6 changes: 6 additions & 0 deletions 6 crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#FFI.verified.cs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -2516,6 +2516,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar

public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null;

public static SpacetimeDB.TableCachePolicy CachePolicy =>
SpacetimeDB.TableCachePolicy.RequiredOnDisk;

/// <summary>
/// Returns the number of rows in this table.
///
Expand Down Expand Up @@ -2715,6 +2718,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar

public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null;

public static SpacetimeDB.TableCachePolicy CachePolicy =>
SpacetimeDB.TableCachePolicy.NoRequirement;

/// <summary>
/// Returns the number of rows in this table.
///
Expand Down
2 changes: 2 additions & 0 deletions 2 crates/bindings-csharp/Codegen/Codegen.csproj
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<IsPackable>false</IsPackable>
<IsRoslynComponent>true</IsRoslynComponent>
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
<DefineConstants>$(DefineConstants);SPACETIMEDB_CODEGEN</DefineConstants>
</PropertyGroup>

<PropertyGroup>
Expand All @@ -37,6 +38,7 @@
<ItemGroup>
<!-- reuse attribute and adjacent types from the runtime -->
<Compile Include="../Runtime/Attrs.cs" />
<Compile Include="../Runtime/Internal/Autogen/TableCachePolicy.g.cs" />
</ItemGroup>

<!-- Local project references (used by SpacetimeDB/modules/*-cs) don't use NuGet resolution. -->
Expand Down
8 changes: 7 additions & 1 deletion 8 crates/bindings-csharp/Codegen/Module.cs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ record TableAccessor
public readonly string? CanonicalName;
public readonly bool IsPublic;
public readonly bool IsEvent;
public readonly TableCachePolicy CachePolicy;
public readonly Scheduled? Scheduled;

public string Identifier => EscapeIdentifier(Name);
Expand All @@ -290,6 +291,7 @@ public TableAccessor(TableDeclaration table, AttributeData data, DiagReporter di
CanonicalName = attr.Name;
IsPublic = attr.Public;
IsEvent = attr.Event;
CachePolicy = attr.CachePolicy;
if (
attr.Scheduled is { } reducer
&& table.GetColumnIndex(data, attr.ScheduledAt, diag) is { } scheduledAtIndex
Expand Down Expand Up @@ -1027,6 +1029,10 @@ public IEnumerable<GeneratedTableAccessor> GenerateTableAccessors()
var accessorIdentifier = v.Identifier;
var iTable =
$"global::SpacetimeDB.Internal.ITableView<{accessorIdentifier}, {globalName}>";
var cachePolicy =
v.CachePolicy == TableCachePolicy.RequiredInMemory
? ""
: $"\n\npublic static SpacetimeDB.TableCachePolicy CachePolicy => SpacetimeDB.TableCachePolicy.{v.CachePolicy};";
var tableArgument = sharedContexts ? "__state" : "";
var rowArgument = sharedContexts ? "row, __state" : "row";
var instanceMembers = sharedContexts
Expand Down Expand Up @@ -1104,7 +1110,7 @@ private static __InstanceState __CreateInstance(int contextInstance)
v.Scheduled is { } scheduled
? $"{iTable}.MakeSchedule(\"{scheduled.ReducerName}\", {scheduled.ScheduledAtColumn})"
: "null"
)}}};
)}}};{{{cachePolicy}}}

/// <summary>
/// Returns the number of rows in this table.
Expand Down
3 changes: 3 additions & 0 deletions 3 crates/bindings-csharp/Runtime/Attrs.cs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ public sealed class TableAttribute : Attribute

public bool Event { get; init; } = false;

/// <summary>The furthest storage tier the table's pages and blobs may reside in.</summary>
public TableCachePolicy CachePolicy { get; init; } = TableCachePolicy.RequiredInMemory;

/// <summary>
/// If set, the name of the reducer that will be invoked when the scheduled time is reached.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion 3 crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV10Section.g.cs
Show comments
View file
Open in desktop

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

35 changes: 35 additions & 0 deletions 35 crates/bindings-csharp/Runtime/Internal/Autogen/RawTableCachePolicyV10.g.cs
Show comments
View file
Open in desktop

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

19 changes: 19 additions & 0 deletions 19 crates/bindings-csharp/Runtime/Internal/Autogen/TableCachePolicy.g.cs
Show comments
View file
Open in desktop

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

2 changes: 2 additions & 0 deletions 2 crates/bindings-csharp/Runtime/Internal/ITable.cs
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public interface ITableView<View, T>

static abstract RawScheduleDefV10? MakeScheduleDesc();

static virtual TableCachePolicy CachePolicy => TableCachePolicy.RequiredInMemory;

static abstract T ReadGenFields(BinaryReader reader, T row);

static virtual string LookupName => tableName;
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.