8374307: Fix deoptimization storm caused by Action_none in GraphKit::uncommon_trap #28966
+2
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We observed a deoptimization storm caused by GraphKit::uncommon_trap generator logic. GraphKit::uncommon_trap considers the too_many_recompiles metric. If the threshold is overflowed, it replaces Deoptimization::Action_reinterpret with Deoptimization::Action_none (see code snippet below).
This replacement changes the uncommon_trap logic: once execution hits a trap, the VM performs deoptimization but does not recompile the method anymore. In an "unlucky" case, when the code part calling this uncommon_trap becomes frequent, a deoptimization storm occurs (thousands of deoptimizations per second) causing a significant performance drop.
The original problematic method, which triggered repeated recompilations, is a high-performance compressed binary serialization algorithm with heavy use of conditional branches driven by bitmasks. See a standalone synthetic benchmark to reproduce the issue.
The issue arises when the method overcomes a global recompilation threshold before stabilizing specific trap counters.
Current thresholds:
Condition: decompile_count() >= (PerMethodRecompilationCutoff / 2) + 1
Default: 201 (derived from default PerMethodRecompilationCutoff = 400).
Checks if the trap count for a specific reason exceeds:
PerMethodTrapLimit (Default: 100) - for Reason_unstable_if, Reason_unstable_fused_if, etc.
PerMethodSpecTrapLimit (Default: 5000) - for Reason_speculate_class_check, Reason_speculate_null_check, etc.
With the gived defaults, if the only reason for the method recompilation is unstable_if, the system stabilizes after 100 traps (PerMethodTrapLimit). However, if the method experiences traps and recompilations for different reasons, the total number of recompilations can exceed 200 before hitting the limit for unstable_if traps. This triggers Action_none and causes the deopt storm.
The proposal is a minimal change in GraphKit::uncommon_trap: apply the same
too_many_recompilesthreshold insideParse::path_is_suitable_for_uncommon_trap- this ensures that on the final recompilation C2 gets a hint not to speculate on untaken branches anymore.As an alternative solution, we can revisit GraphKit::uncommon_trap. This "Temporary fix" has persisted in the codebase for 17 years, so it is probably time to change it as well. Any comments are welcome
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28966/head:pull/28966$ git checkout pull/28966Update a local copy of the PR:
$ git checkout pull/28966$ git pull https://git.openjdk.org/jdk.git pull/28966/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28966View PR using the GUI difftool:
$ git pr show -t 28966Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28966.diff
Using Webrev
Link to Webrev Comment