Expire pending requests instead of keeping them for ever - #36
Merged
Conversation
git-hulk
force-pushed
the
design-request-eviction
branch
from
September 2, 2026 11:45
39b2194 to
3355628
Compare
git-hulk
force-pushed
the
design-request-eviction
branch
from
September 2, 2026 11:46
3355628 to
478c326
Compare
git-hulk
force-pushed
the
design-request-eviction
branch
from
September 2, 2026 11:47
478c326 to
1bdaf17
Compare
git-hulk
force-pushed
the
design-request-eviction
branch
from
September 2, 2026 11:58
1bdaf17 to
6917718
Compare
git-hulk
force-pushed
the
design-request-eviction
branch
from
September 2, 2026 12:15
6917718 to
a34c700
Compare
git-hulk
force-pushed
the
design-request-eviction
branch
from
September 2, 2026 12:24
a34c700 to
d653376
Compare
git-hulk
force-pushed
the
design-request-eviction
branch
from
September 2, 2026 12:26
d653376 to
48fcae1
Compare
git-hulk
force-pushed
the
design-request-eviction
branch
from
September 2, 2026 12:27
48fcae1 to
2f094f0
Compare
Every request went into sniffer->requests and only came out when a
matching response arrived. Requests that were never answered -- a
dropped connection, a server that never replied, a capture that started
mid-response -- stayed for the life of the process, so a long running
capture leaked steadily. It also meant a response arriving minutes
later was still reported as a latency of minutes: replaying a capture
whose answer comes 99 seconds later printed `99000.000 ms`.
- hashtable gains a size counter and hashtable_sweep, which removes
every entry a predicate selects, correctly unlinking at the head,
the middle or the tail of a bucket chain.
- requests_expire drops requests older than 60 seconds of capture
time. The sweep runs at most once per captured second, and is
driven by packet timestamps rather than the wall clock so that
replaying a file behaves the same as a live capture. Timestamps that
go backwards evict nothing.
- 60 seconds is past the last latency bucket, so anything still
waiting is lost rather than useful. MAX_PENDING_REQUESTS is a firm
ceiling for the case where requests arrive faster than they age out.
- hashtable_add now checks its allocations, and no longer half-inserts
an entry whose key could not be duplicated.
Assistant By Opus 5
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
git-hulk
force-pushed
the
design-request-eviction
branch
from
September 2, 2026 12:28
2f094f0 to
9363844
Compare
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.
Every request went into sniffer->requests and only came out when a
matching response arrived. Requests that were never answered -- a
dropped connection, a server that never replied, a capture that started
mid-response -- stayed for the life of the process, so a long running
capture leaked steadily. It also meant a response arriving minutes
later was still reported as a latency of minutes: replaying a capture
whose answer comes 99 seconds later printed
99000.000 ms.hashtable gains a size counter and hashtable_sweep, which removes
every entry a predicate selects, correctly unlinking at the head,
the middle or the tail of a bucket chain.
requests_expire drops requests older than 60 seconds of capture
time. The sweep runs at most once per captured second, and is
driven by packet timestamps rather than the wall clock so that
replaying a file behaves the same as a live capture. Timestamps that
go backwards evict nothing.
60 seconds is past the last latency bucket, so anything still
waiting is lost rather than useful. MAX_PENDING_REQUESTS is a firm
ceiling for the case where requests arrive faster than they age out.
hashtable_add now checks its allocations, and no longer half-inserts
an entry whose key could not be duplicated.
🤖 Generated with Claude Code