Skip to content

Conversation

@vamsi-parasa
Copy link
Contributor

@vamsi-parasa vamsi-parasa commented Nov 20, 2025

The goal of this PR is to fix the performance regression in Arrays.fill() x86 stubs caused by masked AVX stores. The fix is to replace the masked AVX stores with store instructions without masks (i.e. unmasked stores). fill32_masked() and fill64_masked() stubs are replaced with fill32_unmasked() and fill64_unmasked() respectively.

To speedup unmasked stores, array fills for sizes < 64 bytes are broken down into sequences of 32B, 16B, 8B, 4B, 2B and 1B stores, depending on the size.

Performance comparison for byte array fills in a loop for 1 million times

UseAVX=3 ByteArray Size +OptimizeFill (Masked store stub) [secs] -OptimizeFill (No stub) [secs] --->This PR: +OptimizeFill (Unmasked store stub) [secs]
1 0.46 0.14 0.263
2 0.46 0.16 0.264
5 0.46 0.29 0.299
10 0.46 0.58 0.303
15 0.46 0.42 0.271
16 0.46 0.46 0.32
17 0.21 0.5 0.299
20 0.21 0.37 0.299
25 0.21 0.59 0.282
31 0.21 0.53 0.273
32 0.21 0.58 0.199
35 0.5 0.77 0.259
40 0.5 0.61 0.33
45 0.5 0.52 0.281
48 0.5 0.66 0.32
49 0.22 0.69 0.3
50 0.22 0.78 0.3
55 0.22 0.67 0.292
60 0.22 0.67 0.3293
64 0.22 0.82 0.23
70 0.51 1.1 0.34
80 0.49 0.89 0.365
90 0.225 0.68 0.33
100 0.54 1.09 0.347
110 0.6 0.98 0.36
120 0.26 0.75 0.386
128 0.266 1.1 0.289

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8349452: Fix performance regression for Arrays.fill() with AVX512 (Bug - P3)(⚠️ The fixVersion in this issue is [27] but the fixVersion in .jcheck/conf is 26, a new backport will be created when this pr is integrated.)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28442/head:pull/28442
$ git checkout pull/28442

Update a local copy of the PR:
$ git checkout pull/28442
$ git pull https://git.openjdk.org/jdk.git pull/28442/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 28442

View PR using the GUI difftool:
$ git pr show -t 28442

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28442.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 20, 2025

👋 Welcome back sparasa! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Nov 20, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Nov 20, 2025

@vamsi-parasa The following label will be automatically applied to this pull request:

  • hotspot

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@vamsi-parasa vamsi-parasa marked this pull request as ready for review November 20, 2025 23:50
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 20, 2025
@mlbridge
Copy link

mlbridge bot commented Nov 20, 2025

Webrevs

fill64(Address(dst, disp), xmm, use64byteVector);
}

void MacroAssembler::fill32_unmasked(uint shift, Register dst, int disp, XMMRegister xmm,
Copy link

Choose a reason for hiding this comment

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

This could be called as fill32_tail. Also good to replace overall fill32_masked with fill32_tail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see this suggestion incorporated in the updated code.

bind(L_done);
}

void MacroAssembler::fill64_unmasked(uint shift, Register dst, int disp,
Copy link

Choose a reason for hiding this comment

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

This could be called as fill64_tail. Also good to replace overall fill64_masked with fill64_tail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see this suggestion incorporated in the updated code.

Comment on lines 9361 to 9362
fill32_unmasked(shift, to, 0, xtmp, count, rtmp);
jmp(L_exit);
Copy link

Choose a reason for hiding this comment

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

Instead of repeating fill32_unmasked multiple time, you could jmp to say L_fill_32_tail and have the fill32_unmasked code there one time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see this suggestion incorporated in the updated code.

fill64(to, 0, xtmp);
subq(count, 64 >> shift);
fill32_masked(shift, to, 64, xtmp, k2, count, rtmp);
fill32_unmasked(shift, to, 64, xtmp, count, rtmp);
Copy link

Choose a reason for hiding this comment

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

Instead of repeating fill64_unmasked multiple time, you could jmp to say L_fill_64_tail and have the fill64_unmasked code there one time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see this suggestion incorporated in the updated code.

@sviswa7
Copy link

sviswa7 commented Nov 21, 2025

The pre-submit test seem to be unrelated to the PR changes. A fresh merge with tip might resolve those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot [email protected] rfr Pull request is ready for review

Development

Successfully merging this pull request may close these issues.

2 participants