Skip to content

ci(jtreg): run each shard's tests but its slowest at a lower CPU priority, so the slowest one no longer sets the shard's time - #148

Merged
Project516 merged 3 commits into
masterfrom
p516/jtreg-priority
Dec 5, 2026
Merged

Project516 merged 3 commits into
masterfrom
p516/jtreg-priority

Conversation

@Project516

@Project516 Project516 commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Each OpenJDK shard runs 4 tests at a time, slowest first, on a 4-vCPU runner. The slowest test sets the shard's time, and it competes for CPU with the 3 tests beside it. SecurityProviderModularTest takes 80 s with a runner to itself but 240 to 314 s inside its shard, because each of its ~96 child VMs gets a quarter of the CPU.

With --shard and --jobs above 1, the runner now gives every java-web test process except the shard's first one, its slowest by times.tsv, a nice value of 10. Child processes inherit it. The slowest test takes the CPU it needs, and the rest fill the remaining time. No test is skipped and none changes order. Runs without a lead test keep every test at normal priority.

A change to scripts/jtreg/run.ts also changes the key of the TestNG and JUnit jar cache. Every shard then fetched the jars from Maven Central at once, and Maven Central answered 429. The cache step now falls back to the last saved jars (restore-keys), and run.ts still fetches any jar that is missing.

Tests

  • Master's runner and this branch's alternated on the same CI runner, each running the same VM build. Each shard ran 4 tests at a time, 2 runs per side:
Shard master branch
4 of 8, with SecurityProviderModularTest 283 s, 287 s 264 s, 270 s
1 of 8, with RandomCanaryPi 278 s, 262 s 252 s, 253 s

Every test passed in all 8 runs.

  • pnpm typecheck passes.
  • This PR changes scripts/jtreg/run.ts, so its CI runs every OpenJDK test in passing.txt.

@coderabbitai

coderabbitai Bot commented Dec 5, 2026 •

Copy link
Copy Markdown

Explain Change →

Summary

Summary by CodeRabbit

  • Chores
    • Automated test runs can now reuse cached jtreg libraries across runner changes, fetching any missing libraries as needed.
    • In parallel, sharded java-web test runs, tests other than the lead run at lower priority. Other test executions retain their existing priority behavior. This helps balance resources during those CI runs.

The jtreg workflow adds a fallback key for restoring cached libraries. The runner also lowers the priority of non-lead java-web test processes when multiple jobs and shards are active.

Changes: jtreg library cache fallback

Layer / File(s) Summary
Cache restoration
.github/workflows/jtreg.yml
The jtreg library cache uses a jtreg-lib- restore-key prefix. A comment notes that run.ts fetches missing jars.

jtreg test process priority

Layer / File(s) Summary
Lead test and process priority
scripts/jtreg/run.ts
When jobs > 1 and shardN > 1, the first queued test is the lead. The runner requests priority 10 for other java-web test processes when they have a PID. Errors from setting priority are ignored.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Possibly related PRs

Merge Risk: Low · up to 66711

The change lowers the CPU priority of tests sharing a shard with its slowest test, to shorten shard time. A lower-priority test could in principle run slower and hit its unchanged timeout. This is not shown to happen in the current CI setup. The risk is small and any failure would be visible in CI, so this is mergeable with a check of the CI results.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: tests in each shard other than its slowest run at a lower CPU priority, so the slowest test no longer sets the shard's time. The changeset matches this (nice value 10 …
Description check Passed The description follows the template's three sections. 'What this changes' explains the priority change, its conditions, and the jar cache key change. 'Tests' lists benchmark numbers for master and br…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: tests in each shard other than its slowest run at a lower CPU priority, so the slowest test no longer sets the shard's time. The changeset matches this (nice value 10 for non-lead java-web tests when shard and jobs exceed 1). The 'ci(jtreg):' prefix is a conventional-commit style scope, and the title is long but still specific and accurate.

Full details: Description check

Explanation

The description follows the template's three sections. 'What this changes' explains the priority change, its conditions, and the jar cache key change. 'Tests' lists benchmark numbers for master and branch across 8 runs, the typecheck result, and the plan to run the passing.txt OpenJDK tests. 'Noticed, not fixed' is absent, but the template says to delete that section when there are no such problems, so its absence is acceptable.

Finishing Touches

Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the cache at night
Then queues the tests in tidy rows
The lead test keeps its usual pace
The other processes run low
Missing jars are fetched as needed
And carrots mark the finished run

@project516-review-bot project516-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In scripts/jtreg/run.ts, tests other than the shard's slowest (queue[0]) are spawned at nice 10 with os.setPriority, child processes included, so the slowest test keeps the CPU and no longer sets the shard's wall time. The exemption flag is tc !== lead, and lead is undefined unless both jobs > 1 and shardN > 1.


review-bot, model nvidia/nemotron-3.5-super-vl:free, verdict request_changes

Comment thread scripts/jtreg/run.ts Resolved

@project516-review-bot project516-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR adds a low parameter to exec in scripts/jtreg/run.ts that calls os.setPriority(pid, 10) on each spawned test process. When a shard runs with jobs > 1 and shardN > 1, only the queue's first test (the slowest by times.tsv) keeps normal priority; every other test in the shard is deprioritized, and child VMs inherit it. Serial runs and single-shard runs run all tests at normal priority.


review-bot, model nvidia/nemotron-3.5-super-vl:free, verdict approve

@project516-review-bot project516-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR makes every non-lead test in a multi-shard jtreg run start at nice 10, leaving the shard's slowest test (the lead) at normal priority so it gets the CPU it needs and no longer sets the shard's wall time; serial runs stay at normal priority. It also adds a restore-keys fallback to the TestNG/JUnit jar cache so shards reuse saved jars instead of all fetching from Maven Central at once, with run.ts fetching any jar still missing.


review-bot, model nvidia/nemotron-3.5-super-vl:free, verdict approve

@project516-review-bot project516-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In a sharded run with more than one job, the first queued test (the slowest by times.tsv) stays at normal priority and every other test is spawned at nice 10, child processes included, so the slowest test gets CPU precedence without skipping or reordering anything. Serial runs and single-shard runs keep all tests at normal priority. The jtreg-lib cache also gains a restore-keys fallback so a run.ts change no longer causes every shard to re-fetch TestNG and JUnit at once.


review-bot, model nvidia/nemotron-3.5-super-vl:free, verdict approve

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Additional comments: 1

scripts/jtreg/run.ts-610-610: 1

610-610: Major · Stability & Availability · Heavy lift

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Prevent priority changes from causing test timeouts.

When a CPU-bound lead and non-lead compete on a saturated CPU, the non-lead can receive much less CPU time than before. Its unchanged wall-clock timer can then expire even though the test passed at normal priority. Adjust timeout handling for low-priority runs without removing the existing hang protection.

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 9f481ebe-677a-4dd8-bf38-edc5ad08ba4c
Commits

Reviewing files that changed from the base of the PR and between 0ccc505 and 6671130.

Files selected for processing: 2

  • .github/workflows/jtreg.yml
  • scripts/jtreg/run.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Review details

Context from checks skipped due to timeout: 12

  • GitHub Check: CodeRabbit
  • GitHub Check: jtreg / run (8)
  • GitHub Check: jtreg / run (5)
  • GitHub Check: jtreg / run (6)
  • GitHub Check: jtreg / run (4)
  • GitHub Check: jtreg / run (1)
  • GitHub Check: jtreg / run (7)
  • GitHub Check: jtreg / run (3)
  • GitHub Check: jtreg / run (2)
  • GitHub Check: test
  • GitHub Check: Analyze (java-kotlin)
  • GitHub Check: Analyze (javascript-typescript)
Additional comments: 3

.github/workflows/jtreg.yml: 1

79-79: Data Integrity & Integration

The restore prefix can leave obsolete framework jars in build/jtreg/lib. fetchFrameworks() does not place those jars on the test classpath. It builds the classpath only from the four frameworkJars entries and runnerDir. A restored testng-7.2.0.jar therefore cannot be selected alongside the required testng-7.3.0.jar, and no code scans the lib directory for jars.

scripts/jtreg/run.ts: 2

710-710: Performance & Scalability

The lead selection does not need a change. shard returns this shard's tests sorted slowest first, the done filter keeps that order, and line 710 takes the first entry. The sort uses the times.tsv value, or the median for a test with no recorded time, so the lead is the slowest by that estimate.


543-543: Performance & Scalability

The priority call on line 543 runs in the same synchronous step as the spawn on line 537. A test's OS child can only start after the VM has booted and run test code through src/process-node.ts:289. No supported path launches such a child before setPriority runs, so the inheritance race described in the comment is not reachable.

@Project516

Copy link
Copy Markdown
Owner Author

On CodeRabbit's unverified timeout finding (run.ts:610): the lead is one process on a 4-vCPU runner, so the niced tests still share at least 3 vCPUs, and nice 10 only lowers their share when the lead wants CPU. In practice, the branch passed every test in its shard on all 4 same-runner runs (shards 1 and 4, 97 and 96 tests). The full suite also passed on 1f42fbe with no timeouts. The slowest niced test took 217 s against the 600 s limit. No timeout change is needed.

@Project516
Project516 merged commit 79bea17 into master Dec 5, 2026
16 checks passed
@Project516
Project516 deleted the p516/jtreg-priority branch December 5, 2026 02:48
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