perf(relay): defer post-commit dispatch and avoid verify clone#1453
Merged
Conversation
Co-authored-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
Co-authored-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co> Signed-off-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
… clone verify_event only needs a borrow; spawn_blocking only needs 'static. Wrapping the event in an Arc avoids deep-cloning tags + up to 256 KB of content on every ingest. After verification the Arc is uniquely held (the verify task's clone is dropped on completion), so try_unwrap returns the original event; the clone fallback is unreachable in practice but keeps the code total. W8 in PLANS/RELAY_PERF_OPTIMIZATION_PLAN.md; ruled GREEN (no invariant touched) in RESEARCH/RELAY_PERF_CORRECTNESS.md. cargo test -p buzz-relay: 436 passed, 0 failed. Co-authored-by: Tyler Longwell <tlongwell@block.xyz> Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
tlongwell-block
added a commit
that referenced
this pull request
Jul 2, 2026
… p99 −6–28%, p999 tails −29–53% vs PR #1453 tip (#1454) Signed-off-by: Tyler Longwell <tlongwell@block.xyz> Co-authored-by: npub1qyvc0c5kl4gqv2fd97fsk46tu378sqgy35vc83rvgfwne90sel7s0ed67d <011987e296fd5006292d2f930b574be47c7801048d1983c46c425d3c95f0cffd@sprout-oss.stage.blox.sqprod.co> Co-authored-by: Tyler Longwell <tlongwell@block.xyz>
tlongwell-block
pushed a commit
that referenced
this pull request
Jul 2, 2026
Brings the branch current with main (~20 commits, incl. relay perf #1453/#1454 and mention ranking #1431). One conflict resolved in useMentions.ts: kept main's rankMentionCandidates pipeline, re-applied this branch's suggestion slice change (Math.max(MENTION_SUGGESTION_LIMIT, mentionCandidates.length)). Verified post-merge: tsc --noEmit clean, biome check clean, desktop unit tests 1475/1475, cargo check --workspace clean. Co-authored-by: Tyler Longwell <tlongwell@block.xyz> Signed-off-by: Tyler Longwell <tlongwell@block.xyz>
wpfleger96
added a commit
that referenced
this pull request
Jul 2, 2026
…into HEAD * origin/paul/nip-am-agent-turn-metrics: fix(profile): consolidate agent profile runtime metadata (#1451) fix(desktop): simplify workspace rail badges (#1462) perf(desktop): instant channel switching — non-blocking first paint, persisted snapshots (#1452) perf(relay): bounded-concurrency multi-filter query execution (S2) (#1457) fix(desktop): classify timeline prepends so history loads don't bump unread (#1416) fix(desktop): quiet gate for workspace switches instead of boot splash (#1449) fix(read-path): reach complete threads, dense-second timelines, and all people in the GUI (#1418) E1+E3: reduce relay ingest/fan-out DB round trips; ack p99 −7–16%, fd p99 −6–28%, p999 tails −29–53% vs PR #1453 tip (#1454) perf(relay): defer post-commit dispatch and avoid verify clone (#1453) fix(relay): include git hook tools in runtime image (#1326) feat(chart): per-pod emptyDir git scratch when persistence disabled (multi-replica HA) (#1450) fix(relay): remove media bearer-token auth (#1444) fix(desktop): stop search shortcut from hijacking the sidebar (#1447) Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Relay performance stack for the W1/W8 lane:
OKack pathArcStack:
144f00bc—perf(relay): defer post-commit event dispatch605f7127—fix(relay): preserve audit backpressure after W1c61b4c14—perf(relay): share event with sig-verify task via Arc instead of deep cloneCorrectness notes
OKwas never a NIP/repo correctness guarantee; W1 intentionally prioritizes sender-perceivedOKlatency by moving post-commit dispatch after the ack path. The observed local receiver delivery cost is named and accepted below.Validation
Code validation already run on this stack:
cargo fmt --checkcargo test -p buzz-relay handlers::event::testscargo test -p buzz-relayc61b4c149fe30f26e060370fea645412986adf93Benchmark guardrail / tradeoff:
605f7127restored audit backpressure; clean cross-pod p999 recovered to 5.60ms vs raw W1 15.64ms and baseline 6.98ms.c61b4c14: all runs accepted, 0 timeouts; ack p99 remains below baseline across all three protocols; W8 p99 deltas vs W1+fix are ≤0.12ms on 200-byte bodies; guardrail PASS.RESEARCH/RELAY_PERF_BENCH_RUNS/w1fix-605f7127-*andRESEARCH/RELAY_PERF_BENCH_RUNS/w8-c61b4c14-*.