Skip to content

[Testing] Speed up unit test suite: slow-first scheduling and long-pole parallelization - #8641

Open
janezpodhostnik wants to merge 3 commits into
janez/fix-flaky-tests-parallel-exposurefrom
janez/speed-up-unit-test-suite
Open

[Testing] Speed up unit test suite: slow-first scheduling and long-pole parallelization#8641
janezpodhostnik wants to merge 3 commits into
janez/fix-flaky-tests-parallel-exposurefrom
janez/speed-up-unit-test-suite

Conversation

@janezpodhostnik

@janezpodhostnik janezpodhostnik commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Speeds up the full unit test suite (make unittest-main) from ~147s to ~84s median wall time on a 32-core machine, without weakening any assertion (statement coverage verified identical per package before/after).

  • Makefile: schedule the slowest packages first when running the full suite (SLOW_TEST_PACKAGES, only applied for the default ./... package set; CI per-job package subsets are unaffected). go test schedules packages alphabetically, so the long, internally-sequential packages previously started at ~t+60s and formed a straggler tail that dominated the wall time (147s -> 97s).
  • Parallelize long-pole packages whose tests ran fully serially (zero t.Parallel anywhere): scoring registry unit tests and the 5 subtests of TestScoreRegistry_SpamRecordWithoutDuplicateMessagesPenalty (5 sequential 5s require.Never windows now overlap), inspector validation ConfigToggle subtests, ledger compactor tests. All verified to have per-test fixtures and no shared state.
  • connection gater integration test: run the two pubsub silence directions concurrently on two distinct topics (identical 5s never-receive windows, fully isolated), and overlap the pubsub and unicast protocol exchanges (package 65s -> 53s).
  • Compress pacing intervals where assertions are per-heartbeat/per-tick, preserving semantics: ALSP heartbeat and peer manager update interval 1s -> 100ms (RepeatOffender test 21s -> 2s), parallelize the 6 verification happy path subtests (30s -> 8s).
  • scoring libp2p integration tests run in parallel (they use random ports and noop metrics).

Deliberately kept serial: 4 scoring registry/decay tests whose score assertions tolerate only ~5-10% deviation, which the continuous spam-penalty decay exceeds under parallel contention (found via -race stress; parallelism there made them permanently fail, not just slower).

Validation: -race stress runs on all affected packages and repeated 10x full-suite campaigns (10/10 clean).

Depends on: #8640


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

@janezpodhostnik
janezpodhostnik requested a review from a team as a code owner August 4, 2026 18:38
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 35e09b9d-5720-432c-a838-897dc53f7eab

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@janezpodhostnik janezpodhostnik changed the title Speed up unit test suite: slow-first scheduling and long-pole parallelization [Testing] Speed up unit test suite: slow-first scheduling and long-pole parallelization Aug 4, 2026
@janezpodhostnik janezpodhostnik self-assigned this Aug 4, 2026
@janezpodhostnik
janezpodhostnik force-pushed the janez/speed-up-unit-test-suite branch from 7fea36a to c9c39c0 Compare August 7, 2026 13:25
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

4 participants