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

8301404: Factor out os::malloc with os::realloc common code, so that we only have 1 code path #24189

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

gerard-ziemski
Copy link

@gerard-ziemski gerard-ziemski commented Mar 24, 2025

This is the 2nd time I am proposing this (controversial?) change, but this time I do have performance numbers, which indicate no change in speed (using NMTBenchmark from #23786):

proposed:

time:72,642,827[ns]
[samples:807,804] [NMT headers:382,064]
[malloc#:588,703] [realloc#:12,462] [free#:206,639]
memory requested:57,274,288 bytes, allocated:69,004,800 bytes
malloc overhead:4,853,360 bytes [8.47%], NMT headers overhead:6,877,152 bytes [12.01%]
existing code:

time:73,085,446[ns]
[samples:807,804] [NMT headers:382,064]
[malloc#:588,703] [realloc#:12,462] [free#:206,639]
memory requested:57,274,288 bytes, allocated:69,004,800 bytes
malloc overhead:4,853,360 bytes [8.47%], NMT headers overhead:6,877,152 bytes [12.01%]
Note: the NMTBenchmark reports realloc(nullptr) as mallocs(), which is why both versions show the same count for mallocs/reallocs.

The performance is virtually the same where I sampled each test 30 times and took the best (the shortest).

This proposed change factors out the common code and simplifies both os::malloc and os::realloc. We were able to reduce malloc from 44 lines down to 8 (saving of 36 lines) and realloc from 84 to 55 (29 lines).

To me the most important part here is that we reduce the number of times that NMT has to interact with the native allocation code.


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-8301404: Factor out os::malloc with os::realloc common code, so that we only have 1 code path (Enhancement - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24189

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 24, 2025

👋 Welcome back gziemski! 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 Mar 24, 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 Mar 24, 2025

@gerard-ziemski The following label will be automatically applied to this pull request:

  • hotspot-runtime

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.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Mar 24, 2025
@gerard-ziemski gerard-ziemski marked this pull request as ready for review March 27, 2025 23:02
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 27, 2025
@mlbridge
Copy link

mlbridge bot commented Mar 27, 2025

Webrevs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime hotspot-runtime-dev@openjdk.org rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

1 participant