GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
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
|
Actually, I'd prefer that if you don't mind. I think it's a std Mutex because autocomplete chooses it first 🙈 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…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()`.
0d1f8a6 to
7be5914
Compare
Done. :-D Back to you. :-) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
…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.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.