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

Conversation

@kim

@kim kim commented Oct 15, 2026 •
edited by joshua-spacetime
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

Description of Changes

Integrates tiered storage into the rest of the codebase.

This is a big change, because every call site that may access a page or blob
becomes fallible due to the possibility of fault errors.

Much of this is mechanical, but note that transaction commit becomes a two-step
process with this patch: first, all pages and blobs affected by the transaction
are faulted in if necessary, and pinned so they can't be evicted until the
transaction completes. Then, the transaction is actually applied -- this remains
infallible and therefore atomic.

API and ABI breaking changes

Internal only.

Rollback safety impact

N/A

Expected complexity level and risk

5

Testing

Sorry, something went wrong.

Uh oh!

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

All reactions
@kim
kim added this pull request to stack #6306 October 15, 2026 14:44
joshua-spacetime added a commit that referenced this pull request Oct 16, 2026
@joshua-spacetime
Remove added resident storage tests from review diff
8bb3591
Remove nine newly added Deep storage tests (429 lines) at the user's request to reduce the review diff. This removes new coverage for resident/tiered storage, prepared inserts, page reuse, and blob pins. Existing tests from #6305 and all production code remain unchanged.

Validation: 112 existing spacetimedb-table library tests pass; clippy for the library and tests passes with -D warnings.
joshua-spacetime added a commit that referenced this pull request Oct 16, 2026
@joshua-spacetime
Drop macOS-only size assertion adjustments
f1777cf
Remove the local macOS benchmarking accommodations from the review diff. Restore the original unconditional Table=328 assertion and keep TxState=144, which accounts for the inline transaction blob map. Non-macOS compiled code is unchanged.

Native macOS builds again fail the original size checks, as on #6305; a compatibility patch is saved outside the branch for future local profiling.

Validation: rustfmt and git diff --check; exact diff is six deleted lines. Native clippy confirms the expected Table size assertion failure (328 versus 336). Linux checks were not rerun locally.
@kim
kim force-pushed the kim/tiered-storage-integration branch from 7625b27 to b840802 Compare October 19, 2026 06:31
joshua-spacetime
joshua-spacetime reviewed Oct 21, 2026
View reviewed changes
Comment thread crates/table/src/bflatn_to.rs Resolved

Uh oh!

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

Comment thread crates/datastore/src/locking_tx_datastore/committed_state.rs Resolved

Uh oh!

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

Comment thread crates/table/src/table.rs Resolved

Uh oh!

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

joshua-spacetime
joshua-spacetime reviewed Oct 21, 2026
View reviewed changes
Comment thread crates/table/src/table.rs Resolved

Uh oh!

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

joshua-spacetime
joshua-spacetime reviewed Oct 21, 2026
View reviewed changes
Comment thread crates/table/src/table.rs Resolved

Uh oh!

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

joshua-spacetime
joshua-spacetime reviewed Oct 21, 2026
View reviewed changes

@joshua-spacetime joshua-spacetime left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More rollback safety concerns. It would be good to add some rollback tests if they're indeed legitimate.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread crates/core/src/host/wasm_common/module_host_actor.rs Resolved

Uh oh!

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

Comment thread crates/datastore/src/locking_tx_datastore/mut_tx.rs Resolved

Uh oh!

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

Comment thread crates/datastore/src/locking_tx_datastore/mut_tx.rs Resolved

Uh oh!

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

@kim
kim force-pushed the kim/tiered-storage-integration branch from 8c3a919 to 4a229fb Compare October 22, 2026 16:10
@kim
kim removed this pull request from stack #6306 October 22, 2026 16:12
@kim
kim added this pull request to stack #6360 October 22, 2026 16:21
@kim
kim force-pushed the kim/tiered-storage-integration branch 5 times, most recently from f9e3421 to 89a9a07 Compare October 23, 2026 22:51
@kim
kim force-pushed the kim/tiered-storage-integration branch from 89a9a07 to 002db2f Compare October 23, 2026 23:06
joshua-spacetime added a commit that referenced this pull request Oct 29, 2026
@joshua-spacetime
Remove added resident storage tests from review diff
8b28ab7
Remove nine newly added Deep storage tests (429 lines) at the user's request to reduce the review diff. This removes new coverage for resident/tiered storage, prepared inserts, page reuse, and blob pins. Existing tests from #6305 and all production code remain unchanged.

Validation: 112 existing spacetimedb-table library tests pass; clippy for the library and tests passes with -D warnings.
joshua-spacetime added a commit that referenced this pull request Oct 29, 2026
@joshua-spacetime
Drop macOS-only size assertion adjustments
b549af3
Remove the local macOS benchmarking accommodations from the review diff. Restore the original unconditional Table=328 assertion and keep TxState=144, which accounts for the inline transaction blob map. Non-macOS compiled code is unchanged.

Native macOS builds again fail the original size checks, as on #6305; a compatibility patch is saved outside the branch for future local profiling.

Validation: rustfmt and git diff --check; exact diff is six deleted lines. Native clippy confirms the expected Table size assertion failure (328 versus 336). Linux checks were not rerun locally.
@joshua-spacetime
joshua-spacetime force-pushed the kim/tiered-storage-integration branch 3 times, most recently from bb400af to 8eb4f30 Compare October 31, 2026 00:14
@kim
kim removed this pull request from stack #6360 November 3, 2026 07:03
@kim
kim changed the base branch from kim/tiered-storage-base to master November 3, 2026 16:33
@kim
kim added this pull request to stack #6533 November 9, 2026 11:43
@kim @joshua-spacetime
Integrate tiered storage
9be226c
Integrates tiered storage, replacing `Pages` with `PageSet` and
`BlobStore` with `BlobSet`. Handles fallible object acquisition
everywhere.

Also implements two-phase transaction commit, which preflights the
transaction and pins all affected objects. This allows the actual merge
into the committed state to be infallible and therefore atomic.
kim and others added 3 commits November 16, 2026 09:30
@kim
Reclaim local tier objects (#6581)
9a35a8b
Tracks backing storage ownership in the page manager and blob set. After
transactions and under memory budget pressure, orphaned objects are
reclaimed.


# API and ABI breaking changes

N/A

# Rollback safety impact

N/A

# Expected complexity level and risk

3 - Makes the locking protocol in `TieredStorage` more complicated

# Testing

Yes
@joshua-spacetime
Use database-wide eviction instead of per-table (#6586)
6786826
# Description of Changes

Before this change, if a transaction hit the memory limit, it would only
try to evict pages only from the transaction-local set. If no
pages/objects were evict-able, the transaction would fail. Now if no
pages are evict-able, it will try to evict pages from committed set.

# API and ABI breaking changes

N/A

# Rollback safety impact

N/A

# Expected complexity level and risk

2

# Testing

Existing
@kim
Separate namespaces for pages and blobs in disk storage (#6599)
2f1d418
It is possible for a blob to have the same content hash as a page's
`content_hash`, the latter being different from hashing the actually
stored bytes.

To prevent these kinds of collisions, store pages and blobs separately.

# API and ABI breaking changes

N/A

# Rollback safety impact

N/A

# Expected complexity level and risk

1

# Testing

Existing
@joshua-spacetime
joshua-spacetime marked this pull request as ready for review November 16, 2026 19:27
joshua-spacetime added 4 commits November 16, 2026 13:05
@joshua-spacetime
Database-wide eviction for (some) reads (#6607)
c660db7
# Description of Changes

Before this change, a read could hit the resident-memory limit even when
another table had evictable pages. The existing retry could only free
memory from the page or blob set being accessed.

On a resident-memory error, ordinary datastore reads now request
eviction of eligible committed pages and blobs, then retry once. This
covers point lookups, equality and range scans, full-table scans, and
reads used for view maintenance.

Iterators retry the same page or row rather than advancing again, so a
failed attempt cannot cause a row to be skipped. Eviction runs after the
failed access has released its temporary guards. Other errors propagate
normally.

The change uses a borrowed eviction context to call the existing
committed-state trimmer.

# API and ABI breaking changes

None.

# Rollback safety impact

n/a

# Expected complexity level and risk

3

Retries must read the same row without skipping it, and must release
temporary read locks before requesting eviction.

# Testing

Manual.

Updated the keynote benchmark to use a 4MiB cache and updated `transfer`
to read and compare a 2MiB string.

Loading the string forces a blob fault that needs 2 MiB of resident
memory. The cache already contains account pages, leaving insufficient
space.

So before this change:

1. The indexed lookup finds the probe row, whose blob has been evicted
to disk.
2. Loading the blob needs a 2 MiB reservation.
3. The blob store tries evicting other blobs, but there are none it can
evict to make enough room.
4. The accounts table has evictable pages occupying that same memory
budget, but the blob store cannot evict those pages.
5. The read returns `MemoryLimitExceeded`, failing the transfer before
any account updates.

After this change:

1. The same read initially encounters the same allocation failure.
2. Our read-retry handler asks the committed state to evict across
tables.
3. It evicts account pages, freeing enough memory.
4. It retries the same lookup. The blob now fits, its contents are
verified, and the transfer proceeds.
@joshua-spacetime
Acquire db.lock before opening the table cache
aec51d4
@joshua-spacetime
More tiered storage metrics (#6609)
2b39df2
# Description of Changes

Add metrics for local disk failures and reclamation of orphaned cache
objects:

- `spacetime_page_cache_disk_operations_total` and
`spacetime_page_cache_disk_failures_total`: count completed read, write
and delete calls, providing a matching denominator for failure rates.
- `spacetime_page_cache_reclaimed_bytes_total` and
`spacetime_page_cache_reclaimed_objects_total`: count orphaned objects
after successful removal and release of their local-storage permits.
- `spacetime_page_cache_reclamation_duration_seconds`: measures
successful and failed reclamation passes, including locking and
deletion. Calls with nothing pending are excluded.


# API and ABI breaking changes

N/A

# Rollback safety impact

N/A

# Expected complexity level and risk

2

# Testing

None
@joshua-spacetime
Merge branch 'master' into kim/tiered-storage-integration
0564389
joshua-spacetime
joshua-spacetime approved these changes Nov 17, 2026
View reviewed changes
joshua-spacetime added 2 commits November 16, 2026 19:56
@joshua-spacetime
Use bytes::Bytes instead of Arc<[u8]>
8ef39a0
@joshua-spacetime
Rollback failed view materializations
3e19dbd
joshua-spacetime
joshua-spacetime reviewed Nov 17, 2026
View reviewed changes

@joshua-spacetime joshua-spacetime left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kim can you just make sure to update/implement TieredDatabaseStorage::heap_usage() before merging.

Sorry, something went wrong.

Uh oh!

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

All reactions
@joshua-spacetime joshua-spacetime added the release-next Must land in the next release window. Should block a release deployment until merged. label Nov 17, 2026
kim and others added 6 commits November 17, 2026 14:28
@kim
Implement MemoryUsage for TieredDatabaseStorage
ef7b056
@kim
Add module for tiered storage smoketests (#6580)
e5b14af
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Rollback safety impact

<!--
If this PR is safe to roll back after deployment and has no impact on
the rollback safety of any prior PRs, write `n/a` below.

Otherwise, list every prerequisite PR that must be included in a release
before this PR can merge. This PR must not be deployed until each
prerequisite has been deployed and sufficiently observed or tested in
the live deployment that we are confident it will not be rolled back.
Supported forms include #123, SpacetimeDB#123,
#123, and GitHub PR URLs.

Consider whether this PR:
- newly writes to a previously introduced but unused ControlDB table or
reducer, system table, or on-disk data format; or
- clears, deletes, incompatibly changes, or renders unsupported a
previously available ControlDB table or reducer, system table, or
on-disk data format.
-->

# Expected complexity level and risk

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [ ] <!-- maybe a test you want to do -->
- [ ] <!-- maybe a test you want a reviewer to do, so they can check it
off when they're satisfied. -->
@joshua-spacetime
Database-wide eviction for snapshot creation and commitlog replay
1474e62
@joshua-spacetime
Return transaction commit errors to clients instead of panicking
021a1c8
@joshua-spacetime
Surface resident memory budget failures and limits to clients
3a52982
@joshua-spacetime
Exempt connection and publishing metadata from resident memory limits
009a889
@joshua-spacetime
joshua-spacetime added this pull request to the merge queue Nov 18, 2026
Merged via the queue into master with commit 4d685de Nov 18, 2026
74 of 75 checks passed

Uh oh!

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

@kim
kim deleted the kim/tiered-storage-integration branch November 18, 2026 07:29
@kim kim mentioned this pull request Nov 18, 2026
WIP: Base machinery to replace Pages with PageSet #5997
Closed
@clockwork-labs-bot clockwork-labs-bot mentioned this pull request Nov 18, 2026
docs: complete catch-up audit for storage, modules and SDKs #6621
Open
@krisajenkins krisajenkins mentioned this pull request Nov 19, 2026
Use parking_lot's Mutex in BlobSet, so TxState is the same size on macOS #6641
Merged
krisajenkins added a commit that referenced this pull request Nov 19, 2026
@krisajenkins
Use parking_lot's Mutex in BlobSet, so TxState is the same size on ma…
7be5914
…cOS.

On an Apple machine, building the workspace fails in spacetimedb-datastore:

    static_assert_size!(TxState, 144);

reports that TxState is 152 bytes, not 144. Linux CI is happy, so the
assertion looks correct to anyone who only builds there.

The difference comes from BlobSet, added to TxState in #6305 (Integrate
tiered storage). BlobSet holds an `evictable: std::sync::Mutex<Vec<_>>`.
On Linux std's Mutex is a futex word plus a poison flag, 8 bytes in all.
On Apple targets std uses a lazily boxed pthread mutex, a pointer plus a
poison flag, 16 bytes. That puts BlobSet at 96 bytes on macOS against 88
on Linux, and TxState at 152 against 144.

It wasn't caught because every PR CI job that compiles the datastore
runs on Linux or Windows. The only macOS builds are in package.yml,
which runs on tag pushes and manual dispatch, not on pull requests.

Switch `evictable` to parking_lot::Mutex. BlobSet already uses
parking_lot for its RwLock, and parking_lot's Mutex has the same layout
on every platform, so the existing assertion of 144 now holds
everywhere. parking_lot doesn't poison, so the two `.lock().unwrap()`
calls become `.lock()`.
rekhoff pushed a commit that referenced this pull request Nov 20, 2026
@krisajenkins @rekhoff
Use parking_lot's Mutex in BlobSet, so TxState is the same size on ma…
8932a5a
…cOS (#6641)

# Description of Changes

`spacetimedb-datastore` fails to compile on macOS:
`static_assert_size!(TxState, 144)` fails because `TxState` is 152 bytes
there.

The extra 8 bytes come from `BlobSet`, which #6305 added to `TxState`.
Its `evictable` field was a `std::sync::Mutex<Vec<_>>`. On Linux, std's
`Mutex` is a futex word plus a poison flag (8 bytes). On Apple targets
it is a lazily boxed pthread mutex, a pointer plus a poison flag (16
bytes). Measured on aarch64 macOS, `BlobSet` was 96 bytes there against
88 on Linux, which put `TxState` at 152 against 144.

CI didn't catch this because every PR job that compiles the datastore
runs on Linux or Windows. The only macOS builds are in `package.yml`,
which runs on tag pushes and manual dispatch, so the next release
packaging run would probably have hit it.

This PR switches `evictable` to `parking_lot::Mutex`, as suggested in
review. `BlobSet` already uses `parking_lot` for its `RwLock`, and
`parking_lot`'s `Mutex` has the same layout on every platform, so the
existing `static_assert_size!(TxState, 144)` now holds everywhere and is
unchanged. `parking_lot` doesn't poison, so the two `.lock().unwrap()`
calls become `.lock()`.

# API and ABI breaking changes

None. `evictable` is a private field.

# Rollback safety impact

n/a

# Expected complexity level and risk

1. One private field changes mutex type. The lock is only taken in
`evict_inner` and `heap_usage`, and neither relied on poisoning.

# Testing

- Manual: on aarch64 macOS, `spacetimedb-datastore` now compiles with
the unchanged `static_assert_size!(TxState, 144)`. Before this change it
failed with `TxState` at 152 bytes.
- Existing `spacetimedb-table` and `spacetimedb-datastore` tests pass on
aarch64 macOS. These include the `BlobSet` eviction tests, which take
the lock this PR changes.
- Not tested: x86_64 macOS. `parking_lot`'s `Mutex` doesn't depend on
the OS mutex, so its size should be the same there, but I haven't built
it.
Penguinjanator pushed a commit to Penguinjanator/SpacetimeDB that referenced this pull request Nov 20, 2026
@krisajenkins
Use parking_lot's Mutex in BlobSet, so TxState is the same size on ma…
ddd04ee
…cOS (clockworklabs#6641)

# Description of Changes

`spacetimedb-datastore` fails to compile on macOS:
`static_assert_size!(TxState, 144)` fails because `TxState` is 152 bytes
there.

The extra 8 bytes come from `BlobSet`, which clockworklabs#6305 added to `TxState`.
Its `evictable` field was a `std::sync::Mutex<Vec<_>>`. On Linux, std's
`Mutex` is a futex word plus a poison flag (8 bytes). On Apple targets
it is a lazily boxed pthread mutex, a pointer plus a poison flag (16
bytes). Measured on aarch64 macOS, `BlobSet` was 96 bytes there against
88 on Linux, which put `TxState` at 152 against 144.

CI didn't catch this because every PR job that compiles the datastore
runs on Linux or Windows. The only macOS builds are in `package.yml`,
which runs on tag pushes and manual dispatch, so the next release
packaging run would probably have hit it.

This PR switches `evictable` to `parking_lot::Mutex`, as suggested in
review. `BlobSet` already uses `parking_lot` for its `RwLock`, and
`parking_lot`'s `Mutex` has the same layout on every platform, so the
existing `static_assert_size!(TxState, 144)` now holds everywhere and is
unchanged. `parking_lot` doesn't poison, so the two `.lock().unwrap()`
calls become `.lock()`.

# API and ABI breaking changes

None. `evictable` is a private field.

# Rollback safety impact

n/a

# Expected complexity level and risk

1. One private field changes mutex type. The lock is only taken in
`evict_inner` and `heap_usage`, and neither relied on poisoning.

# Testing

- Manual: on aarch64 macOS, `spacetimedb-datastore` now compiles with
the unchanged `static_assert_size!(TxState, 144)`. Before this change it
failed with `TxState` at 152 bytes.
- Existing `spacetimedb-table` and `spacetimedb-datastore` tests pass on
aarch64 macOS. These include the `BlobSet` eviction tests, which take
the lock this PR changes.
- Not tested: x86_64 macOS. `parking_lot`'s `Mutex` doesn't depend on
the OS mutex, so its size should be the same there, but I haven't built
it.
@tamaro-skaljic tamaro-skaljic mentioned this pull request Nov 20, 2026
Upgrade SpacetimeDB tamaro-skaljic/SpacetimeDSL#206
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@joshua-spacetime joshua-spacetime joshua-spacetime approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

release-next Must land in the next release window. Should block a release deployment until merged.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

2 participants

@kim @joshua-spacetime
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 01402775 — 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.