Skip to content

8370315: [IR-Framework] Allow scenarios to be run in parallel#28065

Open
dafedafe wants to merge 23 commits intoopenjdk:masterfrom
dafedafe:JDK-8370315
Open

8370315: [IR-Framework] Allow scenarios to be run in parallel#28065
dafedafe wants to merge 23 commits intoopenjdk:masterfrom
dafedafe:JDK-8370315

Conversation

@dafedafe
Copy link
Contributor

@dafedafe dafedafe commented Oct 30, 2025

Issue

Today, the only practical ways to run IR Framework scenarios in parallel seems to be:

  • spawning threads manually in a single test, or
  • letting jtreg treat each scenario as a separate test (the only way to potentially distribute across hosts).

This makes it a bit cumbersome to use host CPU cores efficiently when running multiple scenarios within the same test.

Change

This change introduces a method TestFramework::startParallel to execute multiple scenarios concurrently. The implementation:

  • launches one task per scenario and runs them in parallel (by default, the maximum concurrency should match the host’s available cores)
  • captures each task’s System.out into a dedicated buffer and flushes it when the task completes to avoid interleaved output between scenarios (Note: only call paths within the compile.lib.ir_framework package are modified to per-task output streams. ProcessTools methods still write directly to stdout, so their output may interleave).
  • adds an option -DForceSequentialScenarios=true to force all scenarios to be run sequentially.

Testing

  • Tier 1-3+
  • explicit ir_framework.tests runs
    • added IR-Framework test TestDForceSequentialScenarios.java to test forcing sequential testing (checkin the output order) and added a parallel run to TestScenatios.java (as well as adding ForceSequentialScenarios flag to TestDFlags.java)

As reference: a comparison of the execution time between sequential and parallel of all IR-Framework tests using scenarios on our machines (linux x64/aarch64, macosx x64/aarch64, windows x64 with different number of cores, so the results for a single test might not be relevant) gave me an average speedup of 1.9.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8370315: [IR-Framework] Allow scenarios to be run in parallel (Enhancement - P4)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28065/head:pull/28065
$ git checkout pull/28065

Update a local copy of the PR:
$ git checkout pull/28065
$ git pull https://git.openjdk.org/jdk.git pull/28065/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28065

View PR using the GUI difftool:
$ git pr show -t 28065

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28065.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 30, 2025

👋 Welcome back dfenacci! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Oct 30, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title JDK-8370315: [IR-Framework] Allow scenarios to be run in parallel 8370315: [IR-Framework] Allow scenarios to be run in parallel Oct 30, 2025
@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Oct 30, 2025
@openjdk
Copy link

openjdk bot commented Oct 30, 2025

@dafedafe The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@dafedafe
Copy link
Contributor Author

The full list of tests using IR-Framework scenarios:

compiler/c2/irTests/gc/ReferenceClearTests.java
compiler/c2/irTests/gc/ReferenceRefersToTests.java
compiler/c2/irTests/igvn/TestCleanMemPhi.java
compiler/c2/irTests/scalarReplacement/AllocationMergesTests.java
compiler/c2/irTests/TestFloat16ScalarOperations.java
compiler/c2/irTests/TestPostParseCallDevirtualization.java
compiler/c2/irTests/TestScheduleSmallMethod.java
compiler/c2/irTests/TestVectorizationMismatchedAccess.java🎲
compiler/gcbarriers/TestG1BarrierGeneration.java
compiler/loopopts/superword/ProdRed_Double.java
compiler/loopopts/superword/ProdRed_Float.java
compiler/loopopts/superword/ProdRed_Int.java
compiler/loopopts/superword/RedTest_int.java
compiler/loopopts/superword/RedTest_long.java
compiler/loopopts/superword/SumRed_Double.java
compiler/loopopts/superword/SumRed_Float.java
compiler/loopopts/superword/SumRed_Int.java
compiler/loopopts/superword/SumRed_Long.java
compiler/loopopts/superword/SumRedAbsNeg_Double.java
compiler/loopopts/superword/SumRedAbsNeg_Float.java
compiler/loopopts/superword/SumRedSqrt_Double.java
compiler/loopopts/superword/TestMemorySegment_8359688.java
compiler/loopopts/superword/TestMemorySegment_ReassociateInvariants1.java
compiler/loopopts/superword/TestMemorySegment_ReassociateInvariants2.java
compiler/loopopts/superword/TestMemorySegmentByteSizeLongLoopLimit.java
compiler/loopopts/superword/TestMemorySegmentField.java
compiler/loopopts/superword/TestMemorySegmentFilterSummands.java
compiler/loopopts/TestArrayFillIntrinsic.java
compiler/vectorization/TestFloatConversionsVector.java

Maybe we could run some of them concurrently (e.g. the ones that show more than a certain speedup to avoid parallelizing short tests that might waste most of the time spawning threads).

@dafedafe dafedafe marked this pull request as ready for review October 31, 2025 16:34
@openjdk openjdk bot added the rfr Pull request is ready for review label Oct 31, 2025
@mlbridge
Copy link

mlbridge bot commented Oct 31, 2025

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Overall looks good, thanks for improving this! I left a few suggestions.

Now the only question remaining is which tests would already benefit from using the parallel version. I guess we can investigate that separately.

Comment on lines +767 to +772
synchronized (printLock) {
String output = baos.toString();
if (!output.isEmpty()) {
System.out.println(output);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

This will probably also not be sorted by scenario index? Could we also just gather it here and then dump it after the stream? Maybe we can put output into Outcome as well as the exceptions by using a ConcurrentSkipListMap<Scenario, Outcome> map in the parallel case or a normal TreeMap in the non-parallel case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea was to print the output as soon as one process finishes, so that we can follow the progress a bit better (and if there is an TestFormatException we have it printed up to the exception, although this could be done later as well). Of course then it is not sorted...
That said, the output would be cleaner and more readable if we printed it in order as you suggest. Maybe we could even interleave output and exceptions for the same scenario. What do you think? (though I just noticed we throw another TestRunException after printing the exceptions)

@dafedafe
Copy link
Contributor Author

dafedafe commented Nov 5, 2025

Now the only question remaining is which tests would already benefit from using the parallel version. I guess we can investigate that separately.

Let me file an RFE for that.

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 4, 2025

@dafedafe This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Sorry, I dropped the ball on this - thanks for the updates! Some more comments but then I think it looks good!

Comment on lines +772 to +775
String output = baos.toString();
if (!output.isEmpty()) {
System.out.println(output);
}
Copy link
Member

Choose a reason for hiding this comment

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

We probably also need to do a similar trick as for the exceptions in order to have ordered stdouts for the scenarios?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be a good idea. Adding it...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@chhagedorn I guess we can drop the printing of exception at the end then. Is that part of what you were suggesting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might have spoken too soon: JTReg seems to collect stdout and stderr and print them out at once at the end of each (JTReg) test. In this case it doesn't make much sense to print out the output of each test as soon as it finishes (it would be better to collect them and print them in order at the end). @chhagedorn, is there possibly a way to make JTReg print the output "on-the-fly" that you are aware of?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I agree. Let's just collect everything, stdout and exceptions, and then print them in scenario index order at the end. That probably also simplifies the logic.

is there possibly a way to make JTReg print the output "on-the-fly" that you are aware of?

I'm not aware of such an option but thought it would be useful in the past when having a long running test and I'm actually only interested in some printed messages at the very start.

Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
dafedafe and others added 3 commits December 12, 2025 18:40
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
…enarios.java

Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
@openjdk openjdk bot removed the rfr Pull request is ready for review label Dec 12, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 12, 2025
@bridgekeeper
Copy link

bridgekeeper bot commented Jan 14, 2026

@dafedafe This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply issue a /touch or /keepalive command to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-compiler hotspot-compiler-dev@openjdk.org rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants