-
Notifications
You must be signed in to change notification settings - Fork 185
JBTM-4023 Implement parallel prepare using Virtual threads (JEP 444) #2445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| * Copyright The Narayana Authors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
| package com.arjuna.ats.arjuna.coordinator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the java21 folder intended for java 21+ use only? @mmusgrov
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just a name for a source root but should be indicative that it's for use with at least java 21.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If later on we need specific code, for say JEP 505: Structured Concurrency (Fifth Preview), then we'd create a new source root such as src/main/java25/, which I'm sure we can find uses for :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for clarifying
d0e9e8c to
645cd29
Compare
ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
Outdated
Show resolved
Hide resolved
ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
Show resolved
Hide resolved
ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
Show resolved
Hide resolved
| * | ||
| * @throws Error JBTM-895 tests, byteman limitation | ||
| */ | ||
| protected final void explicitPhase2Commit (BasicAction theAction, boolean reportHeuristics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC from a different part of the discussion, it would perhaps be appropriate to not have this reportHeuristics argument (and the similar one in explicitPhase2Abort) and just force false on phase2Commit and phase2Abort like we do in the newly deprecated AsyncCommit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So would we want to disallow a future usage where a feature wants to synchronously call doCommit with an explicit BasicAction which seems like a potentially useful thing to do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But I guess such a user would be making changes to BasicAction anyway an could add it back in again if the need were ever to arise. I'll remove the argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose looking at it from that point then the answer is possibly no? But that being said it's a bit more than synchronously calling doCommit. I looked if we might be able to change our existing use of phase2Commit to this new method but I suppose we shouldn't because it would be adding extra calls to handling ThreadActionData. So I think your question is more like would we want to disallow a future usage where a feature wants to synchronously call doCommit with an explicit BasicAction and where they want to manipulate the ThreadActionData stack at the same time - that feels a more narrow use case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although then it's not obvious why reportHeuristics is being forced to be false unless the reader analyses the usages of explicitPhase2Commit and explicitPhase2Abort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit) removes the reportHeuristics arguments to explicitPhase2Commit and explicitPhase2Abort
| * | ||
| * @throws Error JBTM-895 tests, byteman limitation | ||
| */ | ||
| protected final void explicitPhase2Commit (BasicAction theAction, boolean reportHeuristics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose looking at it from that point then the answer is possibly no? But that being said it's a bit more than synchronously calling doCommit. I looked if we might be able to change our existing use of phase2Commit to this new method but I suppose we shouldn't because it would be adding extra calls to handling ThreadActionData. So I think your question is more like would we want to disallow a future usage where a feature wants to synchronously call doCommit with an explicit BasicAction and where they want to manipulate the ThreadActionData stack at the same time - that feels a more narrow use case.
I called it explicitPhase2Commit because the context (BasicAction) is being passed explicitly (like we do with models like REST-AT and JTS) and on that basis manipulating the ThreadActionData stack is the intent behind the method. But I don't mind removing it since a second version of explicitPhase2Commit could be added if such a use case was ever called for. Separately, thanks for approving but I may need a config option: while writing a benchmark I have found it necessary to add an option to enable/disable virtual threads in order to get the comparison (similar to what you asked about](https://github.com/jbosstm/narayana-proposals/pull/3/changes#r2580268195) in your review of the proposal but I need it at runtime. However, the change isn't safe while TwoPhaseCommitThreadPool is in use by BasicAction so I won't be able to commit it. But I will need the option to set it at boot time for benchmarking comparisons which would imply a change to the proposal. |
I added the config option. |
|
I noticed a sporadic failure of AtomicActionAsyncTest.testRegistrationDuringCompletion on my laptop so I added the Hold label while I investigate. |
| arjPropertyManager.getCoordinatorEnvironmentBean().getMaxTwoPhaseCommitThreads()); | ||
| } | ||
|
|
||
| public static boolean isUsingVirtualThreads() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you definitely OK with this and restartExecutor being in the public API? They look like they are used by the test but maybe you anticipate a use case for business logic to need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really. I will create another package, matching the pools package name, for just the restart test .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The isUsingVirtualThreads call is harmless and potentially useful to third parties though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And we do need the close and restart functionality for graceful shutdown and restart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the last push I made the access modifier for TwoPhaseCommitThreadPool.restartExecutor less permissive and used method handles to call it from the test, I also removed the isUsingVirtualThreads and getExecutorClassName methods from the same class.
And I've squashed the similar commits - the only other one that I would have like to squash was the one about not passing the heuristic reporting flag when running async, SHA b65a00f, it contained too many conflicts. The remaining commits contain mostly self-contained modifications which may be useful for future forensic activities. TwoPhaseCommitThreadPool is changed in more than one commit but it would be quite difficult
to pull just those out into a separate commit.
|
FYI I tested the last commit using:
which would fail quite early on in the loop without that last commit. |
| ); | ||
| } | ||
|
|
||
| static void submitJob(java.util.function.Consumer<Boolean> func, boolean reportHeuristics) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer use this so I'll remove it.
tomjenkinson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If all you need to do is remove the the method that you have identified is not used then my approval still stands after that is removed
|
I've added the Hold label while I investigate the java 25 failure (the test run isn't choosing the correct version of the TwoPhaseCommitThreadPool class). |
…ith method references JBTM-4023 Deprecate AsyncCommit and AsyncPrepare and replace with method references. Pass the action context to resource prepare/abort/commit.
… an method to restart the thread pool
…nc since it is ignored (after review)
|
@tomjenkinson The tests are passing now. The earlier failure on the jdk 25 axis was because the surefire plugin wasn't using the java 25 specific version of TwoPhaseCommitThreadPool. I fixed it using maven profiles by defining a separate maven surefire plugin configuration which is activated when testing with java 25, and similarly for java 21 and java 17. The details are in the last commit (SHA ab8af5e JBTM-4023 update poms for testing multi-release jars). The tests on as_builder (17) passed but the builder failure happened on the "Save Narayana Maven repository" step:
|
|
Very nice! Thank you! |
|
I re-approved it but please note the JDK 17 failure |
The tests on as_builder (17) passed but the builder failure happened on the "Save Narayana Maven repository" step:
I'd say it's a GH Action issue, do you have any thoughts about that @jmfinelli |
|
The JDK double as_builder thing will hopefully be fixed by #2462 |
|
The runs passed (https://github.com/jbosstm/narayana/actions/runs/20899006547/job/60095690267?pr=2445) so I'm merging. |
jbosstm/narayana-proposals#3
https://issues.redhat.com/browse/JBTM-4023
JDK17 JDK21 JDK25
CORE
The proposal explains what the PR is adding but briefly it adds support for:
and uses these features to re-implement narayana support for asynchronously preparing participants.
I've staged the implementation in three commits: