-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8322636: [JVMCI] HotSpotSpeculationLog can be inconsistent across a single compile #17183
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
|
👋 Welcome back davleopo! A progress list of the required criteria for merging this PR into |
|
cc @dougxc @tkrodriguez can you have a look |
Webrevs
|
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 think it's worth updating the javadoc for maySpeculate to clarify that it returns consistent results for any given speculation for the lifetime of a SpeculationLog object.
|
@davleopo This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 67 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dougxc, @tkrodriguez) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
@dougxc done - please check |
|
More specifically it only validates against the speculations that failed before the last call to collectFailedSpeculations which must always be called explicitly. And we should point out somewhere that installCode will call collectFailedSpeculations before installation and revalidate the current set of speculations, bailing out if any were violated during compilation. This doesn't seem to be documented anywhere. |
|
@tkrodriguez where do you want to put it? Id suggest to add some additional javadoc to maySpeculate so we end up with something like |
|
So I looked more closely the HotSpot and substrate implementations and I'm not sure we can currently align the implementation and the javadoc. In the HotSpot world, HotSpotSpeculationLog is a compiler local object that reads data from the real speculation data that's kept in the MDO. This means that it has full control over when collectFailedSpeculations is called. SubstrateSpeculationLog is the actual log so if two threads are operating on the same log then one of them could see the effects of a call to collectFailedSpeculations by the other thread. Maybe in practice 2 threads never do this because it would mean they are compiling the same root method but it doesn't seem guaranteed. installCode on substrate also doesn't perform the speculation log check that HotSpot does. So maybe we punt on javadoc updates for now. |
|
I did not consider the substrate runtime compilation use case - that may actually lead to the same error of inconsistency we have seen as here. Probably not relevant now but if it ever pops up we need to relax the invariant on the graal side then. Regarding doc changes - what is our final call now ? (a) drop all new doc again or (b) keep (whatever) form of the new doc I added? - Its hotspot specific so not wrong. |
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 think for now lets just stick with your updates. It does seem like the substrate runtime compilation case is potentially exposed to the original problem but we should address that separately.
|
/integrate |
|
@tkrodriguez please sponsor |
|
/sponsor |
|
Going to push as commit 35a1b77.
Your commit was automatically rebased without conflicts. |
|
@tkrodriguez @davleopo Pushed as commit 35a1b77. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This PR fixes a subtle inconsistency in
HotSpotSpeculationLog.Normal uses of
HotSpotSpeculationLogwork by using aSpeculationReasonand asking the speculation log viamaySpeculateif the speculation can be performed, i.e., if it failed before for the given method. An example for this can be seen in Graal https://github.com/oracle/graal/blob/master/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/nodes/loop/CountedLoopInfo.java#L591C15-L591C15The implicit assumption is that the speculation log,
HotSpotSpeculationLogin particular collects failed speculations at the beginning of a compile and then stays consistent during the compile. Why is that? - Because if there are new failed speculations added to the failed speculations during the compile - the compiler would speculate again on those in an inconsistent way. E.g. at the beginning of a compile a certain speculation has not failed yet and the compiler thinks it can do optimization xyz using a speculation - later during the compilation process it consults the speculation log but gets a different answer. All those inconsistent speculations that already failed will anyway later fail code installation in jvmci (they will throw a bailout duringHotSpotCodeCacheProvider#installCodehttps://github.com/openjdk/jdk/blob/master/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java#L192 ). Thus, we should at least return a consistent result during a compile.The problem for consistency here, that also makes troubles on the graal side, is that
maySpeculateitself can collect failed speculations if there have not been any previously, i.e.,failedSpeculations == null.In order to make the speculation log consistent across an entire JVMCI compile this PR removes the collection of failed speculations in
maySpeculate.Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17183/head:pull/17183$ git checkout pull/17183Update a local copy of the PR:
$ git checkout pull/17183$ git pull https://git.openjdk.org/jdk.git pull/17183/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17183View PR using the GUI difftool:
$ git pr show -t 17183Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17183.diff
Webrev
Link to Webrev Comment