Skip to content
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

x86: Increase inline reference arraycopy threshold #20525

Conversation

a7ehuo
Copy link
Contributor

@a7ehuo a7ehuo commented Nov 7, 2024

This commit increases arraycopyRepMovsReferenceArrayThreshold from 32 bytes to 64 bytes or 128 bytes if AVX-512 is supported

@a7ehuo
Copy link
Contributor Author

a7ehuo commented Nov 7, 2024

@0xdaryl May I ask you to review this change? Thank you!

@vijaysun-omr fyi

This commit increases arraycopyRepMovsReferenceArrayThreshold
from 32 bytes to 64 bytes or 128 bytes if AVX-512 is supported

Signed-off-by: Annabelle Huo <[email protected]>
@a7ehuo a7ehuo force-pushed the system-arraycopy-perf-27-threshold-64-128 branch from fc41c4b to f7dc1d8 Compare November 7, 2024 13:23
@a7ehuo a7ehuo changed the title Increase inline reference arraycopy threshold x86: Increase inline reference arraycopy threshold Nov 7, 2024
int32_t newThreshold = comp->getOptions()->getArraycopyRepMovsReferenceArrayThreshold();

if ((repMovsThresholdBytes < newThreshold) && ((newThreshold == 64) || (newThreshold == 128)))
if ((newThreshold == 32) || (newThreshold == 64) || (newThreshold == 128))
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember being confused by this code when it was first delivered, and with the passage of time I am once again confused.

The documentation for the arraycopyRepMovsReferenceArrayThreshold option says that only 32, 64, or 128 bytes are supported (32 is the default). This means that this if branch should always be taken because the condition on L1905 will always be true. This also means that repMovsThresholdBytes will always be overwritten from what it was set to on L1902.

Is the purpose of the code on L1902 then just in case someone provided an unsupported value for arraycopyRepMovsReferenceArrayThreshold ? If so, I think the code could be written a bit differently to convey that. Specifically, move L1902 as an else to this if and add a comment saying that this path is for when an invalid reference array threshold is provided.

Or am I completely wrong in understanding this logic?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, maybe I have to view this from the perspective of your new OMR PR 7534 alongside this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry my bad, I should have mentioned that this PR should be reviewed together with OMR PR #7534.

Without OMR PR #7534, this PR won't break the build, but it does depend on OMR PR #7534 to get the reference arraycopy threshold properly increased to 64/128.

In OMR PR #7534, the default values for all arraycopyRepMovs*ArrayThresholds are reset to 0 in OMROptions.hpp.

       _arraycopyRepMovsByteArrayThreshold = 0;
       _arraycopyRepMovsCharArrayThreshold = 0;
       _arraycopyRepMovsIntArrayThreshold = 0;
       _arraycopyRepMovsLongArrayThreshold = 0;
       _arraycopyRepMovsReferenceArrayThreshold = 0;

My intended logic is
(1) CG should set the threshold to the proper value: 64 or 128
(2) If someone sets a value in -Xjit options, the threshold will get updated only if the value is valid

@0xdaryl
Copy link
Contributor

0xdaryl commented Nov 12, 2024

Jenkins test sanity xlinux,xmac,win jdk21 depends eclipse-omr/omr#7534

@0xdaryl 0xdaryl merged commit edccce1 into eclipse-openj9:master Nov 13, 2024
12 checks passed
a7ehuo added a commit to a7ehuo/openj9 that referenced this pull request Nov 28, 2024
…raycopy-perf-27-threshold-64-128"

This reverts commit edccce1, reversing
changes made to ec1ae09.

This reduces the threshold for reference arraycopy REP MOVS instructions
back to 32 bytes
0xdaryl added a commit that referenced this pull request Dec 3, 2024
a7ehuo added a commit to a7ehuo/openj9 that referenced this pull request Dec 3, 2024
…raycopy-perf-27-threshold-64-128"

This reverts commit edccce1, reversing
changes made to ec1ae09.

This reduces the threshold for reference arraycopy REP MOVS instructions
back to 32 bytes
pshipton added a commit that referenced this pull request Dec 3, 2024
0xdaryl pushed a commit to 0xdaryl/openj9 that referenced this pull request Dec 19, 2024
…raycopy-perf-27-threshold-64-128"

This reverts commit edccce1, reversing
changes made to ec1ae09.

This reduces the threshold for reference arraycopy REP MOVS instructions
back to 32 bytes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants