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 — Use parking_lot's Mutex in BlobSet, so TxState is the same size on macOS by krisajenkins · Pull Request #6641 · clockworklabs/SpacetimeDB

Conversation

@krisajenkins

@krisajenkins krisajenkins commented Nov 19, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

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

All reactions
@krisajenkins
krisajenkins marked this pull request as ready for review November 19, 2026 16:19
@kim

kim commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

another option is to make evictable a parking_lot::Mutex

Actually, I'd prefer that if you don't mind. I think it's a std Mutex because autocomplete chooses it first 🙈

krisajenkins reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

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

@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()`.
@krisajenkins
krisajenkins force-pushed the kris/macos-txstate-size-assert branch from 0d1f8a6 to 7be5914 Compare November 19, 2026 17:45
@krisajenkins krisajenkins changed the title Make the TxState size assertion target-aware, so the datastore builds on macOS Use parking_lot's Mutex in BlobSet, so TxState is the same size on macOS Nov 19, 2026
@krisajenkins

krisajenkins commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

another option is to make evictable a parking_lot::Mutex

Actually, I'd prefer that if you don't mind. I think it's a std Mutex because autocomplete chooses it first 🙈

Done. :-D

Back to you. :-)

All reactions

Sorry, something went wrong.

Uh oh!

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

kim
kim approved these changes Nov 19, 2026
View reviewed changes

@kim kim left a comment

Copy link
Copy Markdown
Contributor

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.

Thanks!

Sorry, something went wrong.

Uh oh!

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

All reactions
@akotro akotro mentioned this pull request Nov 19, 2026
spacetimedb: 2.15.0 -> 2.16.0 NixOS/nixpkgs#590327
Closed
@krisajenkins
krisajenkins added this pull request to the merge queue Nov 19, 2026
Merged via the queue into master with commit ddd04ee Nov 19, 2026
76 of 77 checks passed

Uh oh!

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

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.
@clockwork-labs-bot clockwork-labs-bot mentioned this pull request Nov 20, 2026
docs: complete catch-up audit for storage, modules and SDKs #6621
Open
@bfops bfops mentioned this pull request Nov 20, 2026
CI - Check macOS and aarch64 Linux builds #6656
Open
1 task done
bfops added a commit that referenced this pull request Nov 20, 2026
@bfops @claude
TEMP: revert #6641 to confirm release_target_check fails
5ae82f2
Co-Authored-By: Claude Opus 5.5 <[email protected]>
bfops added a commit that referenced this pull request Nov 20, 2026
@bfops @claude
Restore #6641 (undo temporary revert)
567df8f
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@krisajenkins
krisajenkins deleted the kris/macos-txstate-size-assert branch November 23, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@kim kim kim approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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

@krisajenkins @kim
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.