perf(relay): defer post-commit dispatch and avoid verify clone#1453
Open
tlongwell-block wants to merge 3 commits into
Open
perf(relay): defer post-commit dispatch and avoid verify clone#1453tlongwell-block wants to merge 3 commits into
tlongwell-block wants to merge 3 commits into
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>
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-*.