Skip to content

Conversation

@ymanton
Copy link
Member

@ymanton ymanton commented Oct 28, 2025

The commits in this PR enable the JIT compiler's fan-in heuristics at >warm opt levels and reduce the method size threshold from 50 bytecodes to 30. Methods that are smaller than the threshold are not considered by the fan-in heuristic. By reducing the threshold we allow more methods to be considered by the heuristic, which tries to prevent inlining of methods that are called from a large number of call sites (i.e. that have a high fan-in). This change shows positive effects on certain benchmarks that have small methods that are called from thousands of call sites.

The patches also add the TR_disableFanInAtHighOpt env var which can be set to prevent the fan-in heuristic from being used at >warm.

(The method size threshold can already be controlled via the -Xjit:iprofilerFaninMethodMinSize= option.)

Allow smaller methods to be considered.

Signed-off-by: Younes Manton <[email protected]>
@ymanton
Copy link
Member Author

ymanton commented Oct 28, 2025

FYI @vijaysun-omr.

I've opened this as a draft for the time being so that I can evaluate some other alternatives. Namely whether enabling fan-in at >warm is worthwhile, whether leaving the threshold size at 50 and instead removing the threshold check from one of the two places it's used in is beneficial, and so on.

@ymanton ymanton marked this pull request as ready for review November 5, 2025 23:48
@ymanton ymanton requested a review from dsouzai as a code owner November 5, 2025 23:48
@vijaysun-omr
Copy link
Contributor

Jenkins test sanity all jdk21

@vijaysun-omr
Copy link
Contributor

@nbhuiyan I would appreciate your review

@vijaysun-omr
Copy link
Contributor

fyi @mpirvu mostly for your awareness

@ymanton
Copy link
Member Author

ymanton commented Nov 6, 2025

Test_openjdk21_j9_sanity.openjdk_aarch64_linux_Personal — Build UNSTABLE

Looks like an existing problem. A similar failure (a different test in the same group of tests, same exception backtrace) from a couple of days ago: https://openj9-jenkins.osuosl.org/job/Test_openjdk21_j9_sanity.openjdk_aarch64_linux_Personal/290/

Build_JDK21_x86-64_windows_Personal — Build FAILED

Failed due to infra issues before it did anything useful.

@vijaysun-omr
Copy link
Contributor

Given the nature of the change (cross platform heuristic) and the known/not real issues in the build, I am going to merge this based on all the other platforms passing

@vijaysun-omr vijaysun-omr merged commit ce51ee0 into eclipse-openj9:master Nov 6, 2025
22 of 25 checks passed
*/
if (comp()->getMethodHotness() > warm)
static bool disableFanInAtHighOpt = feGetEnv("TR_disableFanInAtHighOpt") != NULL;
if (disableFanInAtHighOpt && comp()->getMethodHotness() > warm)
Copy link
Contributor

Choose a reason for hiding this comment

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

Was || intended instead of && here? I would have expected that the behavior (when TR_disableFanInAtHighOpt is not present) would not change.

Copy link
Member Author

Choose a reason for hiding this comment

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

We do want to change the default behaviour and revert to the old behaviour when the env var is set.

The env var isn't there to control the fan-in heuristic in general (that can be done via -Xjit), it's there to quickly revert just this part of the change in case it causes perf regressions or functional issues in the near future. Thanks for double checking it.

Copy link
Contributor

@keithc-ca keithc-ca Nov 6, 2025

Choose a reason for hiding this comment

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

But when the environment variable is not set, disableFanInAtHighOpt == false and the if condition is false.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, that causes control to skip the return and execute the rest of the routine as intended.

Before:

  • Methods compiled at <=warm don't return here and execute the rest of the routine, and are thereby subject to the fan-in heuristic.
  • Methods compiled at >warm return here and aren't subjected to fan-in heuristic.

After:

  • By default no methods return here, they all execute the rest of the routine and are subjected to the fan-in heuristic.
  • If the env var is set, methods compiled at >warm return, are not subject to fan-in; methods <=warm don't return, are subject to fan-in as before.

Copy link
Member

Choose a reason for hiding this comment

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

@keithc-ca That is intentional from my understanding. Now at higher opts, unless TR_disableFanInAtHighOpt is set, we do not do an early return from the method adjustFanInSizeInWeighCallSite. The behaviour prior to this change was that at opt levels > warm, adjustFanInSizeInWeighCallSite was disabled. This PR now allows things to proceed at higher opt levels, with the option to disable it at higher opt levels.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, thanks for the explanations.

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.

4 participants