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 (#6305) · clockworklabs/SpacetimeDB@4d685de

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Cargo.lock
  • Cargo.toml
  • crates
    • bench
      • benches
        • special.rs
      • src
        • spacetime_raw.rs
    • bindings-csharp
      • Codegen.Tests/fixtures/server
        • Lib.cs
        • snapshots
          • Module#FFI.verified.cs
          • Module.net10#FFI.verified.cs
      • Codegen
        • Codegen.csproj
        • Module.cs
      • Runtime
        • Attrs.cs
        • Internal
          • Autogen
            • RawModuleDefV10Section.g.cs
            • RawTableCachePolicyV10.g.cs
            • TableCachePolicy.g.cs
          • ITable.cs
          • ModuleBuilder.cs
    • bindings-macro/src
      • lib.rs
      • table.rs
    • bindings-typescript
      • src/lib
        • autogen
          • types.ts
        • schema.ts
        • table.ts
      • tests
        • cache_policy.test.ts
    • bindings
      • src
        • rt.rs
        • table.rs
      • tests
        • cache_policy.rs
        • ui
          • tables.stderr
          • views.stderr
    • codegen/examples
      • regen-csharp-moduledef.rs
    • core
      • Cargo.toml
      • src
        • db
          • environment.rs
        • error.rs
        • host
          • host_controller.rs
          • idc_actor.rs
          • instance_env.rs
          • module_host.rs
          • scheduler.rs
          • v8
            • mod.rs
            • syscall
              • common.rs
          • wasm_common
            • module_host_actor.rs
          • wasmtime
            • wasm_instance_env.rs
        • sql
          • execute.rs
        • subscription
          • module_subscription_actor.rs
          • module_subscription_manager.rs
          • tx.rs
    • data-structures/src
      • object_pool.rs
    • datastore
      • Cargo.toml
      • src
        • db_metrics
          • mod.rs
          • page_cache.rs
        • error.rs
        • locking_tx_datastore
          • committed_state.rs
          • datastore.rs
          • mut_tx.rs
          • replay.rs
          • state_view.rs
          • tx.rs
          • tx_state.rs
        • system_tables.rs
        • system_tables
          • cache_policy.rs
          • environment.rs
        • traits.rs
    • dst/src
      • engine.rs
    • engine/src
      • persistence.rs
      • relational_db.rs
      • sql
        • ast.rs
      • update.rs
    • execution/src
      • lib.rs
      • pipelined.rs
    • fs-utils/src
      • dir_trie.rs
    • lib/src/db/raw_def
      • v10.rs
    • paths/src
      • server.rs
    • portable-datastore/src
      • lib.rs
    • sats/src
      • layout.rs
    • schema
      • src
        • auto_migrate.rs
        • auto_migrate
          • formatter.rs
          • termcolor_formatter.rs
        • def.rs
        • def/validate
          • v10.rs
          • v9.rs
        • error.rs
        • schema.rs
      • tests
        • ensure_same_schema.rs
    • smoketests/modules
      • Cargo.lock
      • Cargo.toml
      • tiered-storage
        • Cargo.toml
        • src
          • lib.rs
    • snapshot
      • src
        • lib.rs
        • remote.rs
      • tests
        • remote.rs
    • standalone
      • Cargo.toml
      • src
        • lib.rs
    • table
      • Cargo.toml
      • benches
        • page.rs
        • page_manager.rs
      • proptest-regressions
        • table.txt
        • tiered
          • blob_set.txt
      • src
        • bflatn_from.rs
        • bflatn_to.rs
        • blob_store.rs
        • eq.rs
        • eq_to_pv.rs
        • lib.rs
        • page.rs
        • page_pool.rs
        • pages.rs
        • read_column.rs
        • row_hash.rs
        • static_bsatn_validator.rs
        • static_layout.rs
        • table.rs
        • table_index
          • bytes_key.rs
          • mod.rs
        • tiered
          • blob_set.rs
          • budget.rs
          • error.rs
          • map.rs
          • mem.rs
          • metrics.rs
          • metrics
            • labels.rs
          • mod.rs
          • page_manager.rs
          • page_ref.rs
          • page_set.rs
          • storage.rs
          • storage
            • tests.rs
            • tests
              • blobs.rs
              • races.rs
              • reclamation.rs
        • var_len.rs
    • test-datastore/src
      • lib.rs
    • testing/tests
      • idc_actor.rs
    • tiered-storage
      • Cargo.toml
      • src
        • lib.rs

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Cargo.lock‎

Copy file name to clipboardExpand all lines: Cargo.lock
+24Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎Cargo.toml‎

Copy file name to clipboardExpand all lines: Cargo.toml
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ members = [
3434
"crates/sats",
3535
"crates/schema",
3636
"crates/smoketests",
37+
"crates/tiered-storage",
3738
"sdks/csharp/test-harness~",
3839
"sdks/rust",
3940
"sdks/unreal",
@@ -199,6 +200,7 @@ spacetimedb-subscription = { path = "crates/subscription", version = "=2.16.0" }
199200
spacetimedb-sql-parser = { path = "crates/sql-parser", version = "=2.16.0" }
200201
spacetimedb-table = { path = "crates/table", version = "=2.16.0" }
201202
spacetimedb-test-datastore = { path = "crates/test-datastore", version = "=2.16.0" }
203+
spacetimedb-tiered-storage = { path = "crates/tiered-storage", version = "=2.16.0" }
202204

203205
# Prevent `ahash` from pulling in `getrandom` by disabling default features.
204206
# Modules use `getrandom02` and we need to prevent an incompatible version
@@ -221,6 +223,7 @@ blake3 = "1.5.1"
221223
brotli = { version = "3.5", default-features = false, features = ["std"] }
222224
bytemuck = { version = "1.16.2", features = ["must_cast"] }
223225
bytes = "1.10.1"
226+
bytesize = "2.0.1"
224227
bytestring = { version = "1.2.0", features = ["serde"] }
225228
cargo_metadata = "0.17.0"
226229
chrono = { version = "0.4.24", default-features = false }
Collapse file

‎crates/bench/benches/special.rs‎

Copy file name to clipboardExpand all lines: crates/bench/benches/special.rs
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use spacetimedb_lib::sats::{self, bsatn};
99
use spacetimedb_lib::{bsatn::ToBsatn as _, ProductValue};
1010
use spacetimedb_schema::schema::TableSchema;
1111
use spacetimedb_schema::table_name::TableName;
12-
use spacetimedb_table::page_pool::PagePool;
12+
use spacetimedb_table::tiered::{EvictionPolicy, PageManager};
1313
use spacetimedb_testing::modules::{Csharp, ModuleLanguage, Rust};
1414
use std::sync::Arc;
1515
use std::sync::OnceLock;
@@ -141,24 +141,25 @@ fn serialize_benchmarks<
141141
let mut table = spacetimedb_table::table::Table::new(
142142
Arc::new(table_schema),
143143
spacetimedb_table::indexes::SquashedOffset::COMMITTED_STATE,
144+
PageManager::new_for_test().into(),
145+
EvictionPolicy::NeverEvict,
144146
);
145-
let pool = PagePool::new_for_test();
146-
let mut blob_store = spacetimedb_table::blob_store::HashMapBlobStore::default();
147+
let blob_store = spacetimedb_table::tiered::BlobSet::new_for_test();
147148

148149
let ptrs = data_pv
149150
.elements
150151
.iter()
151152
.map(|row| {
152153
table
153-
.insert(&pool, &mut blob_store, row.as_product().unwrap())
154+
.insert(&blob_store, row.as_product().unwrap())
154155
.unwrap()
155156
.1
156157
.pointer()
157158
})
158159
.collect::<Vec<_>>();
159160
let refs = ptrs
160161
.into_iter()
161-
.map(|ptr| table.get_row_ref(&blob_store, ptr).unwrap())
162+
.map(|ptr| table.get_row_ref(&blob_store, ptr).unwrap().unwrap())
162163
.collect::<Vec<_>>();
163164
group.bench_function(format!("bflatn_to_bsatn_slow_path/count={count}"), |b| {
164165
b.iter(|| {
Collapse file

‎crates/bench/src/spacetime_raw.rs‎

Copy file name to clipboardExpand all lines: crates/bench/src/spacetime_raw.rs
+9-6Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use crate::{
33
schemas::{table_name, BenchTable, IndexStrategy},
44
ResultBench,
55
};
6-
use spacetimedb::db::relational_db::{tests_utils::TestDB, RelationalDB};
6+
use spacetimedb::{
7+
db::relational_db::{tests_utils::TestDB, RelationalDB},
8+
error::DatastoreError,
9+
};
710
use spacetimedb_datastore::execution_context::Workload;
811
use spacetimedb_primitives::{ColId, IndexId, TableId};
912
use spacetimedb_sats::{bsatn, AlgebraicValue};
@@ -120,8 +123,8 @@ impl BenchDatabase for SpacetimeRaw {
120123
.db
121124
.iter_mut(tx, *table_id)?
122125
.take(row_count as usize)
123-
.map(|row| row.to_product_value())
124-
.collect::<Vec<_>>();
126+
.map(|row| row.map(|r| r.to_product_value()))
127+
.collect::<Result<Vec<_>, DatastoreError>>()?;
125128

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

139142
assert_eq!(
@@ -160,7 +163,7 @@ impl BenchDatabase for SpacetimeRaw {
160163
fn iterate(&mut self, table_id: &Self::TableId) -> ResultBench<()> {
161164
self.db.with_auto_commit(Workload::Internal, |tx| {
162165
for row in self.db.iter_mut(tx, *table_id)? {
163-
black_box(row);
166+
black_box(row?);
164167
}
165168
Ok(())
166169
})
@@ -174,7 +177,7 @@ impl BenchDatabase for SpacetimeRaw {
174177
) -> ResultBench<()> {
175178
self.db.with_auto_commit(Workload::Internal, |tx| {
176179
for row in self.db.iter_by_col_eq_mut(tx, *table_id, col_id, &value)? {
177-
black_box(row);
180+
black_box(row?);
178181
}
179182
Ok(())
180183
})
Collapse file

‎crates/bindings-csharp/Codegen.Tests/fixtures/server/Lib.cs‎

Copy file name to clipboardExpand all lines: crates/bindings-csharp/Codegen.Tests/fixtures/server/Lib.cs
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,15 @@ public static void Init(ReducerContext ctx)
212212
}
213213
}
214214

215-
[SpacetimeDB.Table(Accessor = "MultiTable1", Public = true)]
216-
[SpacetimeDB.Table(Accessor = "MultiTable2")]
215+
[SpacetimeDB.Table(
216+
Accessor = "MultiTable1",
217+
Public = true,
218+
CachePolicy = SpacetimeDB.TableCachePolicy.RequiredOnDisk
219+
)]
220+
[SpacetimeDB.Table(
221+
Accessor = "MultiTable2",
222+
CachePolicy = SpacetimeDB.TableCachePolicy.NoRequirement
223+
)]
217224
public partial struct MultiTableRow
218225
{
219226
[SpacetimeDB.Index.BTree(Table = "MultiTable1")]
Collapse file

‎crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs‎

Copy file name to clipboardExpand all lines: crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar
22382238

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

2241+
public static SpacetimeDB.TableCachePolicy CachePolicy =>
2242+
SpacetimeDB.TableCachePolicy.RequiredOnDisk;
2243+
22412244
/// <summary>
22422245
/// Returns the number of rows in this table.
22432246
///
@@ -2374,6 +2377,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar
23742377

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

2380+
public static SpacetimeDB.TableCachePolicy CachePolicy =>
2381+
SpacetimeDB.TableCachePolicy.NoRequirement;
2382+
23772383
/// <summary>
23782384
/// Returns the number of rows in this table.
23792385
///
Collapse file

‎crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#FFI.verified.cs‎

Copy file name to clipboardExpand all lines: crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module.net10#FFI.verified.cs
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar
25162516

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

2519+
public static SpacetimeDB.TableCachePolicy CachePolicy =>
2520+
SpacetimeDB.TableCachePolicy.RequiredOnDisk;
2521+
25192522
/// <summary>
25202523
/// Returns the number of rows in this table.
25212524
///
@@ -2715,6 +2718,9 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar
27152718

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

2721+
public static SpacetimeDB.TableCachePolicy CachePolicy =>
2722+
SpacetimeDB.TableCachePolicy.NoRequirement;
2723+
27182724
/// <summary>
27192725
/// Returns the number of rows in this table.
27202726
///
Collapse file

‎crates/bindings-csharp/Codegen/Codegen.csproj‎

Copy file name to clipboardExpand all lines: crates/bindings-csharp/Codegen/Codegen.csproj
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<IsPackable>false</IsPackable>
1212
<IsRoslynComponent>true</IsRoslynComponent>
1313
<EnforceExtendedAnalyzerRules>true</EnforceExtendedAnalyzerRules>
14+
<DefineConstants>$(DefineConstants);SPACETIMEDB_CODEGEN</DefineConstants>
1415
</PropertyGroup>
1516

1617
<PropertyGroup>
@@ -37,6 +38,7 @@
3738
<ItemGroup>
3839
<!-- reuse attribute and adjacent types from the runtime -->
3940
<Compile Include="../Runtime/Attrs.cs" />
41+
<Compile Include="../Runtime/Internal/Autogen/TableCachePolicy.g.cs" />
4042
</ItemGroup>
4143

4244
<!-- Local project references (used by SpacetimeDB/modules/*-cs) don't use NuGet resolution. -->
Collapse file

‎crates/bindings-csharp/Codegen/Module.cs‎

Copy file name to clipboardExpand all lines: crates/bindings-csharp/Codegen/Module.cs
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ record TableAccessor
278278
public readonly string? CanonicalName;
279279
public readonly bool IsPublic;
280280
public readonly bool IsEvent;
281+
public readonly TableCachePolicy CachePolicy;
281282
public readonly Scheduled? Scheduled;
282283

283284
public string Identifier => EscapeIdentifier(Name);
@@ -290,6 +291,7 @@ public TableAccessor(TableDeclaration table, AttributeData data, DiagReporter di
290291
CanonicalName = attr.Name;
291292
IsPublic = attr.Public;
292293
IsEvent = attr.Event;
294+
CachePolicy = attr.CachePolicy;
293295
if (
294296
attr.Scheduled is { } reducer
295297
&& table.GetColumnIndex(data, attr.ScheduledAt, diag) is { } scheduledAtIndex
@@ -1027,6 +1029,10 @@ public IEnumerable<GeneratedTableAccessor> GenerateTableAccessors()
10271029
var accessorIdentifier = v.Identifier;
10281030
var iTable =
10291031
$"global::SpacetimeDB.Internal.ITableView<{accessorIdentifier}, {globalName}>";
1032+
var cachePolicy =
1033+
v.CachePolicy == TableCachePolicy.RequiredInMemory
1034+
? ""
1035+
: $"\n\npublic static SpacetimeDB.TableCachePolicy CachePolicy => SpacetimeDB.TableCachePolicy.{v.CachePolicy};";
10301036
var tableArgument = sharedContexts ? "__state" : "";
10311037
var rowArgument = sharedContexts ? "row, __state" : "row";
10321038
var instanceMembers = sharedContexts
@@ -1104,7 +1110,7 @@ private static __InstanceState __CreateInstance(int contextInstance)
11041110
v.Scheduled is { } scheduled
11051111
? $"{iTable}.MakeSchedule(\"{scheduled.ReducerName}\", {scheduled.ScheduledAtColumn})"
11061112
: "null"
1107-
)}}};
1113+
)}}};{{{cachePolicy}}}
11081114
11091115
/// <summary>
11101116
/// Returns the number of rows in this table.
Collapse file

‎crates/bindings-csharp/Runtime/Attrs.cs‎

Copy file name to clipboardExpand all lines: crates/bindings-csharp/Runtime/Attrs.cs
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ public sealed class TableAttribute : Attribute
8585

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

88+
/// <summary>The furthest storage tier the table's pages and blobs may reside in.</summary>
89+
public TableCachePolicy CachePolicy { get; init; } = TableCachePolicy.RequiredInMemory;
90+
8891
/// <summary>
8992
/// If set, the name of the reducer that will be invoked when the scheduled time is reached.
9093
/// </summary>

0 commit comments

Comments
0 (0)
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.