perf(relay): sweep intro_times on the background tick, off the hot intro path#348
Merged
Conversation
…tro path evict_stale_intro_nicks (a retain over up to MAX_INTRO_TRACKING_NICKS = 10k entries) ran on-demand inside handle_intro under the global lock whenever the map crossed the soft cap — a 10k scan on the hot, unauthenticated intro path that blocks every other relay handler while held. Add a proactive sweep to the existing 60s pair-sweeper tick so the map rarely reaches that threshold; the on-demand sweep stays as a backstop, so the memory bound is unchanged — only the common-case eviction moves off the hot path. (Bug-hunt relay-locks dimension, #14. The sibling #7 finding — explicit caps on the slot-keyed maps — is noted not coded: responder_health is already transitively bounded by MAX_SLOTS, and a slot-TTL reaper is a semantic change (slots never expire today) deferred for separate design.) Test sweep_intro_times_drops_aged_nicks_off_the_hot_path. 609 lib tests; fmt + clippy clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jun 27, 2026
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.
evict_stale_intro_nicks(aretainover up toMAX_INTRO_TRACKING_NICKS= 10k entries) ran on-demand insidehandle_introunder the global lock whenever the map crossed the soft cap — a 10k scan on the hot, unauthenticated intro path that blocks every other relay handler while held.Add a proactive sweep to the existing 60s pair-sweeper tick so the map rarely reaches that threshold; the on-demand sweep stays as a backstop, so the memory bound is unchanged — only the common-case eviction moves off the hot path.
Bug-hunt relay-locks dimension, #14. The sibling #7 (explicit caps on slot-keyed maps) is noted-not-coded:
responder_healthis already transitively bounded byMAX_SLOTS(a slot must exist to set health), and a slot-TTL reaper is a semantic change (slots never expire today) deferred for separate design.Test
sweep_intro_times_drops_aged_nicks_off_the_hot_path;cargo test --lib→ 609; fmt + clippy clean.🤖 Generated with Claude Code