test: Rebalance parallel test scheduling and trim fixture overhead - #2199
Merged
Conversation
vdusek
marked this pull request as ready for review
August 27, 2026 10:18
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2199 +/- ##
==========================================
- Coverage 93.73% 93.73% -0.01%
==========================================
Files 181 181
Lines 12825 12825
==========================================
- Hits 12022 12021 -1
- Misses 803 804 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Pijukatel
approved these changes
Aug 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The unit suite spends most of its wall-clock waiting. On a reference CI job (
ubuntu-latest / 3.14, run 33047203526) the main pass does 578 worker-seconds of work in 131.8s across 8 workers and burns 476 of them idle.--dist loadseeds each worker with a fixed chunk of consecutive tests and never reassigns, sogw4was still running_playwright/test_utils.pyat 125s with the other seven idle for about a minute. Perfect balance would finish at 72.3s.Same failure mode as apify/apify-client-python#1037.
Changes
--dist workstealinaddoptsso an idle worker takes over tests still queued on a busy one. Nothing in the repo usesxdist_group, and--distis inert without-n.proxyanddisabled_proxyare session-scoped and sync. Each teardown blocks ~1s on proxy.py's hardcodedselector.select(timeout=1); with 17 servers built and destroyed that is ~17 worker-seconds of pure waiting. The server is a stateless forwarder, so one per session is enough. Sync because a session-scoped async fixture is incompatible withasyncio_default_fixture_loop_scope = "function", and neither ever awaited.--numprocesses=1from therun_alonepass - it paid the full xdist worker bootstrap for a 15-test serial suite.COVERAGE_CORE=sysmononunit-tests-cov. Measured on a 1397-test subset: default core +14%, sysmon +0%. Coverage falls back with a warning wheresys.monitoringis unavailable, so 3.10 and 3.11 are safe.test_infinite_scroll_on_dynamic_pagewaits on the page instead of the clock - fourwait_for_timeout(1000)sleeps for aloadMore()that awaits 100ms, on the critical-path worker.Measured
Full suite, both passes, same machine, two reps each: ~114s -> ~74s (-35%). These runs are without coverage, so change 4 is not reflected. 2456 tests pass on both sides;
ruff format,ruff checkandtyare clean.Not in this PR
from crawlee.crawlers import HttpCrawlercosts 3.51s, of which 1.28s is scikit-learn and scipy, imported eagerly by_adaptive_playwright._rendering_type_predictor(behind the optionaladaptive-crawlerextra). Every worker pays it, as does everycrawlee[all]cold start. Not a one-liner -RenderingTypePredictorStateneedsLogisticRegressionat class-creation time. Worth its own issue.apify/workflows.tests_concurrency: "8"may be 2x oversubscription on 4-vCPU runners; worth one run withnprocechoed and an-n4comparison.test_http_2still hits the real internet - it needs an HTTP/2 endpoint the local uvicorn server does not speak.✍️ Drafted by Claude Code