Skip to content

Expire pending requests instead of keeping them for ever - #36

Merged
git-hulk merged 1 commit into
masterfrom
design-request-eviction
Sep 2, 2026
Merged

Expire pending requests instead of keeping them for ever#36
git-hulk merged 1 commit into
masterfrom
design-request-eviction

Conversation

@git-hulk

@git-hulk git-hulk commented Sep 2, 2026

Copy link
Copy Markdown
Owner

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

@git-hulk
git-hulk force-pushed the design-request-eviction branch from 39b2194 to 3355628 Compare September 2, 2026 11:45
@git-hulk
git-hulk force-pushed the design-request-eviction branch from 3355628 to 478c326 Compare September 2, 2026 11:46
@git-hulk
git-hulk force-pushed the design-request-eviction branch from 478c326 to 1bdaf17 Compare September 2, 2026 11:47
@git-hulk
git-hulk force-pushed the design-request-eviction branch from 1bdaf17 to 6917718 Compare September 2, 2026 11:58
@git-hulk
git-hulk force-pushed the design-request-eviction branch from 6917718 to a34c700 Compare September 2, 2026 12:15
@git-hulk
git-hulk force-pushed the design-request-eviction branch from a34c700 to d653376 Compare September 2, 2026 12:24
@git-hulk
git-hulk force-pushed the design-request-eviction branch from d653376 to 48fcae1 Compare September 2, 2026 12:26
@git-hulk
git-hulk force-pushed the design-request-eviction branch from 48fcae1 to 2f094f0 Compare September 2, 2026 12:27
Base automatically changed from design-stats-locking to master September 2, 2026 12:28
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
git-hulk force-pushed the design-request-eviction branch from 2f094f0 to 9363844 Compare September 2, 2026 12:28
@git-hulk
git-hulk merged commit ac6ee3d into master Sep 2, 2026
6 checks passed
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