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

8308105: Multi-array allocations are very slow #22829

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

bulasevich
Copy link
Contributor

@bulasevich bulasevich commented Dec 19, 2024

The performance issue arises from transforming new int[size1][size2] into a costly hotspot runtime call that allocates the main array and then sequentially allocates subarrays.

During the C2 parse phase, expressions with constant sizes, such as new int[2][2], are optimized into a series of AllocateArray nodes. These nodes are compiled into inline TLAB allocations, avoiding runtime calls.

This change aims at optimising the case of multidimensional arrays of variable size. For such cases, a Parse::expand_multianewarray2 will generate a c2 graph equivalent to array = new int[size1][]; for (int i=0; i<size1; i++) { array[i] = new int[size2] } expression.

Change produces good performance results:

Benchmark                  (size)  (size2)  Mode  Cnt   Score    Error   Units
ArrayAllocation.full (before) 128        2  avgt    4  540.707 ± 12.154  ns/op
ArrayAllocation.full (after)  128        2  avgt    4   12.713 ±  0.435  ns/op
ArrayAllocation.piecemeal     128        2  avgt    4   12.966 ±  0.297  ns/op

Status:

  • jtreg almost passed (the only fail is shenandoah specific assertion "expect memory state" in MemoryGraphFixer::collect_memory_nodes)
  • needs more testing

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-8308105: Multi-array allocations are very slow (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22829

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 19, 2024

👋 Welcome back bulasevich! 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 Dec 19, 2024

❗ 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 Dec 19, 2024

@bulasevich The following label will be automatically applied to this pull request:

  • hotspot-compiler

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.

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

Successfully merging this pull request may close these issues.

1 participant