Skip to content

perf(relay): sweep intro_times on the background tick, off the hot intro path#348

Merged
laulpogan merged 1 commit into
mainfrom
fix/relay-map-bounds
Jun 20, 2026
Merged

perf(relay): sweep intro_times on the background tick, off the hot intro path#348
laulpogan merged 1 commit into
mainfrom
fix/relay-map-bounds

Conversation

@laulpogan

Copy link
Copy Markdown
Collaborator

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 (explicit caps on slot-keyed maps) is noted-not-coded: responder_health is already transitively bounded by MAX_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

…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>
@laulpogan laulpogan merged commit 9964c0f into main Jun 20, 2026
13 checks passed
@laulpogan laulpogan deleted the fix/relay-map-bounds branch June 20, 2026 02:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant