WIP: sharing slice 1 PR 2: fenced room delivery #835

Closed
kayg wants to merge 1 commit from feat/sharing-s1-pr2-rooms into feat/sharing-s1-pr2
Owner

Part 2 room-delivery layer, stacked on #829 and targeting feat/sharing-s1-pr2.

Moved from #829: shared-room frames carry their note sequence and admitted recipient epoch. The socket writer checks the current grant interval, committed server fence, and recipient epoch immediately before writing. Revocation advances the recipient epoch and evicts the recipient's room subscriptions.

The send lock is scoped per recipient and owner note. Grant and revoke acquire the recipient lock before the note writer lock; revoke keeps it through room eviction. The regression test covers progress for another recipient while one delivery is slow.

#829 remains dormant: cross-owner resolution is refused and sharing actions remain unregistered.

Changed lines: 1,131 (1,048 additions, 83 deletions).

Gates on dev-01

  • PASS: cargo fmt --all -- --check
  • PASS: cargo clippy --workspace --all-targets -j4 -- -D warnings
  • PASS: cargo test --workspace -j4 (89 successful test-result groups; perf-only tests remain ignored)
Part 2 room-delivery layer, stacked on #829 and targeting `feat/sharing-s1-pr2`. Moved from #829: shared-room frames carry their note sequence and admitted recipient epoch. The socket writer checks the current grant interval, committed server fence, and recipient epoch immediately before writing. Revocation advances the recipient epoch and evicts the recipient's room subscriptions. The send lock is scoped per recipient and owner note. Grant and revoke acquire the recipient lock before the note writer lock; revoke keeps it through room eviction. The regression test covers progress for another recipient while one delivery is slow. #829 remains dormant: cross-owner resolution is refused and sharing actions remain unregistered. Changed lines: **1,131** (1,048 additions, 83 deletions). ## Gates on dev-01 - PASS: `cargo fmt --all -- --check` - PASS: `cargo clippy --workspace --all-targets -j4 -- -D warnings` - PASS: `cargo test --workspace -j4` (89 successful test-result groups; perf-only tests remain ignored)
feat(sharing): move room delivery into stacked PR
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled
5766dbce21
Author
Owner

Moved room delivery from #829 to isolate sequence-bearing frames, the last-moment grant/fence/epoch check, and revoke eviction. Added recipient-scoped send locks so a slow delivery does not block other recipients; the concurrency regression and all three dev-01 gates pass.

Moved room delivery from #829 to isolate sequence-bearing frames, the last-moment grant/fence/epoch check, and revoke eviction. Added recipient-scoped send locks so a slow delivery does not block other recipients; the concurrency regression and all three dev-01 gates pass.
Author
Owner

BM14's two auth failures are owned by the dormant resolver integration in #829, not this room transport layer. Fix 97d790f6 is pushed there, with 30/30 merged-tree auth suite passes under one ordinary slot build, preserving recipient refusal and owner cache/sequence assertions. Evidence: #829 (comment). This branch remains unchanged; no train rerun or merge into dev.

BM14's two auth failures are owned by the dormant resolver integration in #829, not this room transport layer. Fix `97d790f6` is pushed there, with 30/30 merged-tree auth suite passes under one ordinary slot build, preserving recipient refusal and owner cache/sequence assertions. Evidence: https://git.kayg.org/kayg/calternal/pulls/829#issuecomment-76545. This branch remains unchanged; no train rerun or merge into dev.
Author
Owner

Perf fix pushed (head 46be23e3): the same owner fast path as #829 (merged in, resolved to this branch's room-delivery code), plus the owner shortcut at the socket writer (Notes::authorize_delivery, epoch 0 only). Culprit analysis and tables are on #829 and #897. Access logic touched: owner Read/Edit/delivery of own note with non-app-password credentials only; recipients and app passwords unchanged. Tests: auth 65, notes 551 pass; fmt clean.

Method: release binaries built on dev-01, relayed to the perf VMs with matching sha256 (dev de99cfbf…, train+fixes 68dd30a0…, same dev calternal-perf for every run). Every run under ~/bin/perf-lock, seed 1, 10k Home, alternating pairs. Medians of per-run p50 / p95, [min–max of p50]. The perf VMs were shared with other agents' long lock holds, so runs spread over several windows; dev-vs-dev spread alone is 0.20–0.37 ms on round trip.

sync.round_trip bisect (10k, perf-02, ms)

Build p50 p95 runs
dev 41f2efa3 0.302–0.327 0.41–0.43 5
train through #829 (ef284146) 0.418 (+34%) 0.547 (+33%) 5
train through #835 (efa2bf37) 0.548 (+77%) 0.766 (+87%) 4
#829 + fix (72eb0eb1) vs dev same window 0.217 vs 0.235 0.337 vs 0.344 5
#835 + owner-delivery fixes only (F3) 0.351 vs 0.327 (+7%) 0.451 vs 0.417 5
train + all fixes (TF2) vs dev, 10k 0.286 vs 0.290 0.388 vs 0.401 5

Culprits: #829 (Auth::authorize_room_delivery, called per delivered frame, does a sharing-db read even for the owner's own note) and #835 (the same check per queued frame in the room, again per written frame in live.rs, plus two more reads per room join and a clone of the caller). Both are the same cause: an owner reading their own note never depends on a grant row, but every frame paid a database hop.

Final train + fixes vs dev, both sizes (3 pairs, ms; p50 / p95)

Metric Home dev train+fixes note
sync.round_trip 10k 0.214 / 0.351 0.231 / 0.341 p95 flat, p50 +8% inside range overlap
sync.round_trip 100k 0.246 / 0.353 0.288 / 0.379 p50 +17%, p95 +7%: n=3, ranges overlap, not shown flat
sync.save_ack 10k / 100k 2.63 / 4.41, 3.31 / 5.11 3.11 / 4.17, 3.27 / 4.68 flat or better
open.note 10k 0.710 / 1.183 0.787 / 1.408 +11% / +19%, n=3
open.note 100k 4.81 / 9.49 4.47 / 10.64 flat / +12%
open.api_get 10k / 100k 3.47 / 9.94, 5.04 / 12.2 3.31 / 10.95, 5.12 / 10.9 flat
Earlier 5-pair 10k run of the same binary: round_trip 0.286 / 0.388 vs dev 0.290 / 0.401, open.note 0.817 / 1.531 vs 0.815 / 1.440 (flat). I could not get more 100k pairs through the shared lock; 100k round_trip needs a longer paired run before it can be called flat.
Perf fix pushed (head `46be23e3`): the same owner fast path as #829 (merged in, resolved to this branch's room-delivery code), plus the owner shortcut at the socket writer (`Notes::authorize_delivery`, epoch 0 only). Culprit analysis and tables are on #829 and #897. Access logic touched: owner Read/Edit/delivery of own note with non-app-password credentials only; recipients and app passwords unchanged. Tests: auth 65, notes 551 pass; fmt clean. Method: release binaries built on dev-01, relayed to the perf VMs with matching sha256 (dev `de99cfbf…`, train+fixes `68dd30a0…`, same dev `calternal-perf` for every run). Every run under `~/bin/perf-lock`, seed 1, 10k Home, alternating pairs. Medians of per-run p50 / p95, [min–max of p50]. The perf VMs were shared with other agents' long lock holds, so runs spread over several windows; dev-vs-dev spread alone is 0.20–0.37 ms on round trip. ### sync.round_trip bisect (10k, perf-02, ms) | Build | p50 | p95 | runs | |---|---|---|---| | dev `41f2efa3` | 0.302–0.327 | 0.41–0.43 | 5 | | train through #829 (`ef284146`) | 0.418 (+34%) | 0.547 (+33%) | 5 | | train through #835 (`efa2bf37`) | 0.548 (+77%) | 0.766 (+87%) | 4 | | #829 + fix (`72eb0eb1`) vs dev same window | 0.217 vs 0.235 | 0.337 vs 0.344 | 5 | | #835 + owner-delivery fixes only (F3) | 0.351 vs 0.327 (+7%) | 0.451 vs 0.417 | 5 | | **train + all fixes (TF2) vs dev, 10k** | **0.286 vs 0.290** | **0.388 vs 0.401** | 5 | Culprits: **#829** (`Auth::authorize_room_delivery`, called per delivered frame, does a sharing-db read even for the owner's own note) and **#835** (the same check per queued frame in the room, again per written frame in `live.rs`, plus two more reads per room join and a clone of the caller). Both are the same cause: an owner reading their own note never depends on a grant row, but every frame paid a database hop. ### Final train + fixes vs dev, both sizes (3 pairs, ms; p50 / p95) | Metric | Home | dev | train+fixes | note | |---|---|---|---|---| | sync.round_trip | 10k | 0.214 / 0.351 | 0.231 / 0.341 | p95 flat, p50 +8% inside range overlap | | sync.round_trip | 100k | 0.246 / 0.353 | 0.288 / 0.379 | **p50 +17%, p95 +7%: n=3, ranges overlap, not shown flat** | | sync.save_ack | 10k / 100k | 2.63 / 4.41, 3.31 / 5.11 | 3.11 / 4.17, 3.27 / 4.68 | flat or better | | open.note | 10k | 0.710 / 1.183 | 0.787 / 1.408 | +11% / +19%, n=3 | | open.note | 100k | 4.81 / 9.49 | 4.47 / 10.64 | flat / +12% | | open.api_get | 10k / 100k | 3.47 / 9.94, 5.04 / 12.2 | 3.31 / 10.95, 5.12 / 10.9 | flat | Earlier 5-pair 10k run of the same binary: round_trip 0.286 / 0.388 vs dev 0.290 / 0.401, open.note 0.817 / 1.531 vs 0.815 / 1.440 (flat). I could not get more 100k pairs through the shared lock; 100k round_trip needs a longer paired run before it can be called flat.
Author
Owner

Review of the owner fast path (both heads, 72eb0eb1 / 46be23e3) is on #829: #829 (comment)

Short version: safe to train, 0 P1 / 2 P2 / 4 P3. On this PR: P2.1 applies to sharing.rs:984, P2.2 to the live-writer fast path at lib.rs:965 (no revoked-app-password test), P3.3 to sharing.rs:2211 and P3.6 to that fast path running before self.enter(owner). The 100k sync.round_trip and open.note numbers are still the merge gate.

Review of the owner fast path (both heads, `72eb0eb1` / `46be23e3`) is on #829: https://git.kayg.org/kayg/calternal/pulls/829#issuecomment-77281 Short version: safe to train, 0 P1 / 2 P2 / 4 P3. On this PR: P2.1 applies to `sharing.rs:984`, P2.2 to the live-writer fast path at `lib.rs:965` (no revoked-app-password test), P3.3 to `sharing.rs:2211` and P3.6 to that fast path running before `self.enter(owner)`. The 100k `sync.round_trip` and `open.note` numbers are still the merge gate.
Author
Owner

Landed in dev via 12103f1c97 — closing.

Landed in dev via 12103f1c973f1e810dd4a9a3bff5a705514d70b0 — closing.
kayg closed this pull request 2026-11-07 17:53:16 +00:00
Some checks failed
CI / server (pull_request) Has been cancelled
CI / rust (pull_request) Has been cancelled
CI / web (pull_request) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal!835
No description provided.