feat: speed up incoming packet parsing - #1830
Conversation
Merging this PR will improve performance by 43.28%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_parse_incoming_message |
466.4 µs | 254.3 µs | +83.36% |
| ⚡ | test_unique_payloads |
3 ms | 2.7 ms | +11.96% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing speed_up_incoming_parser (59acf2c) with master (e63bf6f)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1830 +/- ##
=======================================
Coverage 99.86% 99.87%
=======================================
Files 33 33
Lines 3839 3883 +44
Branches 553 567 +14
=======================================
+ Hits 3834 3878 +44
Misses 3 3
Partials 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
59015cd to
8448b77
Compare
|
Just waiting for ASAN locally |
|
local ASan 50,000 hostile packets + all 14 audit boundary packets, zero sanitizer reports. |
Matches static audit. Traced all buffer reads independently: header, questions, record header, SRV, character string, string, NSEC bitmap, name fast path, label pointer. Each guarded before dereference. Label slice correctly stays on One gap: fuzz strategies cap at |
|
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Nobody is pickling DNSIncoming, that would be a crazy use case. Its not intended to be a public API. This is an internal safety |
Fair — dropping that finding. Grepped repo: nothing pickles or copies |
PR Review — feat: speed up incoming packet parsingApproving. All three notes from my previous pass are now addressed or dismissed by the author; nothing blocking remains. Re-verified against the current head (the branch moved from What changed since the last review, and how it lands:
🟢 Suggestions
1. Boundary fuzz test only ever exercises the record-drop path
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Summary
Speeds up
DNSIncomingparsing by 47 percent; the benchmark packet drops from 9.3µs to 4.9µs on the compiled build. Stacked on #1829 so the fuzzing suite guards every change.Details
_read_bitmapindexes the buffer directly instead of allocating a bytes slice per NSEC record, and skips zero bytesDNSIncomingnow refuses pickling,datais readonly, both closing lifetime holes the raw pointer would otherwise openTest plan
poetry run pytest testspasses, 495 passed; pre-commit clean; Cython annotate maps show the added score confined to cold raise blocks and the 8x slow path