test: add codspeed benchmarks for listener duplicate-packet dedup#1744
Conversation
Adds three benchmarks that pin AsyncListener._process_datagram_at_time under packet streams that exercise the dedup branch differently: - test_dedup_hit_same_payload — steady-state dedup hit (one payload repeated). - test_alternating_payloads — A, B, A, B, ... The single-slot remembered-last-packet dedup misses on every packet, so all 200 flood through DNSIncoming parse. This is the shape from issue python-zeroconf#1724 and the path python-zeroconf#1743 fixes. - test_unique_payloads — 200 distinct payloads, never deduped on either implementation. Pins the miss-path storage cost. Landing on master ahead of python-zeroconf#1743 lets CodSpeed compare before/after on the same PR so we can demonstrate the alternating-flood improvement does not come at the cost of regressing the steady- state hit or unique-stream paths.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1744 +/- ##
=======================================
Coverage 99.76% 99.76%
=======================================
Files 33 33
Lines 3455 3455
Branches 478 478
=======================================
Hits 3447 3447
Misses 5 5
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merging this PR will degrade performance by 8.25%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes |
PR Review — test: add codspeed benchmarks for listener duplicate-packet dedupClean benchmark addition. Three benchmarks isolate the dedup branch cleanly: 🟢 Suggestions1. async_close not in finally — leaks on benchmark failure (`tests/benchmarks/test_listener_dedup.py`, L71-88)If 2. Frozen `t` may not exercise the same code path on both implementations (`tests/benchmarks/test_listener_dedup.py`, L76-83)All three benchmarks freeze Checklist
SummaryClean benchmark addition. Three benchmarks isolate the dedup branch cleanly: Automated review by Kōan1b88ce8 |
Rebase with requested adjustmentsBranch StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
What
Three CodSpeed benchmarks for
AsyncListener._process_datagram_at_time, exercising the duplicate-packet suppression branch under different stream shapes.Why
#1743 replaces the single-slot remembered-last-packet dedup (
self.data) with a bounded recency window keyed on payload bytes. Landing benchmarks ahead of that change lets CodSpeed compare before/after on the same PR — so we can demonstrate the alternating-flood improvement does not come at the cost of regressing the steady-state hit or unique-stream paths.Verified on master:
test_alternating_payloads: 200/200 packets bypass dedup (the bug from Security: Duplicate-packet suppression only compares to the most recent packet, allowing trivial bypass #1724).test_dedup_hit_same_payload: 1/200 reach parse (steady-state dedup works).After #1743 lands, CodSpeed should show a large speedup on the alternating case and roughly flat results on the other two.
How
tests/benchmarks/test_listener_dedup.py— three@pytest.mark.asynciobenchmarks following thetest_send.pypattern (AsyncZeroconfon loopback,async_closein teardown so the project-wideverify_threads_endedfixture stays green)._InertListenersubclassesAsyncListenerand stubshandle_query_or_defer, holding the post-dedup work constant across implementations so any delta is attributable to the dedup branch itself.registry.has_entries = Truedirectly instead of round-trippingasync_register_servicethrough the event loop — the realistic code path stays live without paying registration cost in setup._FLAGS_QR_QUERY) without QU questions so the dedup branch is eligible.Testing
Behavioural check on master (instrumented
handle_query_or_defercount):Quality Report
Changes: 1 file changed, 128 insertions(+)
Code scan: clean
Tests: passed (4 PASSED)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline