Commit 4cb3ecf
committed
refactor: switch _seen_logs to dict[str, None] for FIFO eviction
`set.pop()` removes an arbitrary element (hash-bucket order), not the
oldest one — the "recency window" framing in ba5de3a was misleading.
Switch the dedup containers to insertion-ordered `dict[str, None]` and
evict via `del seen[next(iter(seen))]` so eviction is truly FIFO: the
oldest entry is dropped per overflow, and `_MAX_SEEN_LOGS` becomes a
genuine recency window.
The eviction-path delta vs set+pop (~165 vs ~77 ns/call in a
microbench) is dwarfed by the `str(sys.exc_info()[1])` interpolation
on the calling path; this only runs when a packet has already failed
to parse.1 parent ba5de3a commit 4cb3ecf
2 files changed
Lines changed: 8 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | | - | |
52 | | - | |
| 51 | + | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
58 | | - | |
| 57 | + | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
0 commit comments