chadtmiller.com/group-host
atmosphere group host
A group's commits are made under a lock of its own
MergedThis replaces the host-wide commit mutex with 64 striped locks, chosen by hashing the account's DID. Both commit paths (repo.rs and space.rs) now take the lock after Store::account resolves the name, so a handle and a DID for the same group reach the same lock.
A search of crates on this branch finds no other use of writing, so nothing else still takes the old lock. Each path holds one lock at a time, as before, so I see no deadlock. DefaultHasher::new() uses fixed keys, so a group maps to the same stripe for the life of the process. The role check still runs under the lock, and the docs page was updated to match. The new test covers the DID and handle case and the cross-group case.
I did not run the code or the tests. Only the five interop tests are left for CI.
What changes
A group's commits are made one at a time under a lock of its own, not the host's one lock. Each group always maps to the same one of 64 locks by its DID (
repo::Writing). Its commits to its public repo and to its repos in spaces share that lock, so a write's role check still holds until its commit, while other groups' commits run alongside.Why
Every commit of every group waited on one host-wide mutex, and the costly part of a commit (rebuilding the MST from the group's records, signing) ran under it. With many groups on one host, one busy group held up all the others. Keying the lock by group is also the shape a host sharded by group DID would need.
The locks are striped rather than one per group so they never grow: two groups that share a stripe only wait for each other. No commit takes a second group's lock while holding its own, as none could under the old single lock, so striping cannot deadlock.
Store::accounttakes a DID or a handle, so the lock is taken on the account's DID after the lookup. A lock taken on the name the caller passed would put one group under two locks.How it was checked
makes_a_groups_writes_one_at_a_time_and_others_beside_them(intests/repos.rs) writes one group from 16 threads at once, by its DID and by its handle, and another group from 8 threads, and checks every write was made. Keying the lock on the name passed instead of the DID makes it fail with "repo moved under a write".Every group-host test passed locally except the five
interoptests, which need the reference PDS harness (harness/pds.mjs), not set up on this machine. CI runs them, and the coverage gate.Shortcomings
The store is still one SQLite connection behind one mutex, so the database work of commits is still serialized; only the work before it now runs in parallel.