Skip to content

Improve ValidatesRunner performance. Parallelize runs - #40292

Merged
reuvenlax merged 5 commits into
apache:masterfrom
reuvenlax:merge_validates_runner
Sep 30, 2026
Merged

reuvenlax merged 5 commits into
apache:masterfrom
reuvenlax:merge_validates_runner

Conversation

@reuvenlax

@reuvenlax reuvenlax commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Large test classes ParDoTest$StateTests, PAssertTest, MapViewTest, ViewTest, ParDoTest$TimerTests, SplittableDoFnTest executed their @test methods 1-at-a-time on their assigned Gradle worker, spending >99% of their time blocked in waitUntilFinish() polling remote Dataflow jobs. Gradle4 does not natively parallelize tests within a test class.

Fix:
BeamParallelJunit4Runner: A JUnit 4 runner extending BlockJUnit4ClassRunner that dispatches @test methods within a class concurrently onto a shared fixed thread pool per worker JVM, with independent parallelism controls for ValidatesRunner vs. other tests. For now we modify only ValidatesRunner tests to use this, but in the future we can extend to more test suites.

A small number of tests were unsafe for parallel execution. Some of them were fixable (e.g. use of a static HashMap which we replaced with a ConcurrentHashMap). Others are fundamentally unsafe (e.g. any test that checks for specific log entries), and those have been marked with the SerialTest annotation to prevent parallelizing them.

@codecov

codecov Bot commented Sep 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.69231% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.57%. Comparing base (3afe19a) to head (b48a04f).
⚠️ Report is 20 commits behind head on master.

Files with missing lines Patch % Lines
...pache/beam/sdk/util/construction/Environments.java 82.60% 2 Missing and 6 partials ⚠️
...apache/beam/runners/dataflow/util/PackageUtil.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master   #40292      +/-   ##
============================================
+ Coverage     56.14%   58.57%   +2.42%     
- Complexity     2288    13739   +11451     
============================================
  Files          1121     2579    +1458     
  Lines        177152   270095   +92943     
  Branches       1488    11172    +9684     
============================================
+ Hits          99467   158205   +58738     
- Misses        75161   105890   +30729     
- Partials       2524     6000    +3476     
Flag Coverage Δ
java 64.88% <82.69%> (-10.84%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@github-actions

Copy link
Copy Markdown
Contributor

Assigning reviewers:

R: @chamikaramj for label java.
R: @Abacn for label build.

This pull request likely touches a core component ("core" label). Please review with scrutiny.

Note: If you would like to opt out of this review, comment assign to next reviewer.

Available commands:

  • stop reviewer notifications - opt out of the automated review tooling
  • remind me after tests pass - tag the comment author after tests pass
  • waiting on author - shift the attention set back to the author (any comment or push by the author will return the attention set to the reviewers)

The PR bot will only process comments in the main thread (not review comments).

@reuvenlax
reuvenlax force-pushed the merge_validates_runner branch from e2ae93f to f4d293b Compare September 29, 2026 19:56
@github-actions github-actions Bot removed the build label Sep 29, 2026
@reuvenlax reuvenlax changed the title [POC] Improve ValidatesRunner performance. Phase 0 [POC] Improve ValidatesRunner performance. Parallelize runs Sep 30, 2026
@reuvenlax

Copy link
Copy Markdown
Contributor Author

Note: Java ValidatesRunner finished in about 1hr. About 15 minutes of that was compilation time (it appears our remote build cache is not working). The actual test suite finished in about 45 minutes - a significant improvement from 6 hours!

@kennknowles kennknowles left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation of the runner has some classic coding agent stuff, like being overspecified (specialized to ValidatesRunner as opposed to just general) and doing things in sort of a too-literal / not abstract enough way, but it works and helps right now and we can improve it if we need to. It does not have major readability issues so it is OK.

@reuvenlax

Copy link
Copy Markdown
Contributor Author

@kennknowles it isn't specialized to ValidatesRunner - the only specialization is that there is ValidatesRunner-specific parallelism, because I wanted the ability to configure a different parallelism for NeedsRunner tests.

@reuvenlax reuvenlax changed the title [POC] Improve ValidatesRunner performance. Parallelize runs Improve ValidatesRunner performance. Parallelize runs Sep 30, 2026
@reuvenlax
reuvenlax merged commit 43bd833 into apache:master Sep 30, 2026
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants