Skip to content

test: drop ZeroconfServiceTypes.find() timeouts from 500ms to 200ms on loopback#1710

Merged
bdraco merged 2 commits into
masterfrom
perf/tests-tighten-find-timeouts
May 18, 2026
Merged

test: drop ZeroconfServiceTypes.find() timeouts from 500ms to 200ms on loopback#1710
bdraco merged 2 commits into
masterfrom
perf/tests-tighten-find-timeouts

Conversation

@bdraco
Copy link
Copy Markdown
Member

@bdraco bdraco commented May 17, 2026

Summary

Part of #1707 (slow tests sweep). Bucket C of a 3-PR series (follows #1708, #1709).

ZeroconfServiceTypes.find() is implemented as a bare time.sleep(timeout) — it doesn't short-circuit on the first matching response — so the timeout argument becomes a lower bound on test runtime. The integration-with-listener tests each call find() twice and pay 1.0s of pure sleep on top of ~200ms of registration setup. On loopback the registrar's response lands within a few ms, so 200ms is ~50× headroom.

test_async_zeroconf_service_types also slept 200ms after async_register_service to let the final announce broadcast land. That test already has the quick_timing fixture (which patches _REGISTER_TIME=10ms), so 50ms is plenty.

Speedups:

test before after
test_integration_with_listener 1.28s 0.67s
test_integration_with_subtype_and_listener 1.27s 0.66s
test_integration_with_listener_v6_records 1.27s 0.67s
test_integration_with_listener_ipv6 (same pattern, not in #1707) 0.67s
test_async_zeroconf_service_types 1.54s 0.77s

Stable across 3 sequential runs. No production change.

The cleaner long-term fix is making find() event-driven (return as soon as expected types arrive) — left for a follow-up since that's an API-shape change.

Test plan

  • Targeted tests pass three times in a row
  • Full tests/ suite passes (337 passed, 3 IPv6 skips)
  • Pre-commit hooks pass

@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.76%. Comparing base (91aa21d) to head (6424140).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1710   +/-   ##
=======================================
  Coverage   99.76%   99.76%           
=======================================
  Files          33       33           
  Lines        3426     3426           
  Branches      471      471           
=======================================
  Hits         3418     3418           
  Misses          5        5           
  Partials        3        3           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 17, 2026

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing perf/tests-tighten-find-timeouts (6424140) with master (91aa21d)

Open in CodSpeed

bdraco added 2 commits May 17, 2026 17:46
…n loopback

`ZeroconfServiceTypes.find()` is just `time.sleep(timeout)` (it
doesn't short-circuit on the first matching response), so the
timeout becomes a lower bound on the test runtime. Each of these
tests calls `find()` twice, paying 1s of pure sleep on top of
~200ms of setup. On loopback the registrar's response lands within
a few ms, so 200ms is ~50× headroom.

`test_async_zeroconf_service_types` also slept 200ms after
`async_register_service` to let the last announce broadcast land —
that one already has the `quick_timing` fixture (which patches
_REGISTER_TIME=10ms), so 50ms is plenty.

Speedups:
- test_integration_with_listener: 1.28s → 0.67s
- test_integration_with_subtype_and_listener: 1.27s → 0.66s
- test_integration_with_listener_v6_records: 1.27s → 0.67s
- test_integration_with_listener_ipv6 (same pattern, not in #1707
  list): 0.67s
- test_async_zeroconf_service_types: 1.54s → 0.77s
The 0.2s `ZeroconfServiceTypes.find()` / `async_find()` timeout used
by the four loopback service-types tests was a bare float literal at
ten call sites. Hoist it to a `LOOPBACK_FIND_TIMEOUT` constant in
`tests/__init__.py` so the rationale lives in one place.
@bdraco bdraco force-pushed the perf/tests-tighten-find-timeouts branch from cfd311b to 6424140 Compare May 18, 2026 00:50
@bdraco bdraco merged commit 64d143d into master May 18, 2026
69 of 70 checks passed
@bdraco bdraco deleted the perf/tests-tighten-find-timeouts branch May 18, 2026 01:41
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