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

8332139: SymbolTableHash::Node allocations allocates twice the required memory #19214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xmas92
Copy link
Member

@xmas92 xmas92 commented May 13, 2024

The symbols are inline and allocated together with the ConcurrentHashTable (CHT) Nodes. The calculation used for the required size is alloc_size = size + value.byte_size() + value.effective_length();

Where

  • size == sizeof(SymbolTableHash::Node) == sizeof(void*) + sizeof(Symbol)
  • value.byte_size() == dynamic_sizeof(Symbol) == sizeof(Symbol) + <bytes beyond object>
  • value.effective_length() == dynamic_sizeof(Symbol) - sizeof(Symbol) == <bytes beyond object>

So alloc_size ends up being sizeof(void*) /* node metadata */ + 2 * dynamic_sizeof(Symbol)

Because using the CHT with dynamically sized (and inlined) types requires knowing about its implementation details I chose to make the functionality for calculating the the allocation size a property of the CHT. It now queries the CHT for the node allocation size given the dynamic size required for the VALUE.

The only current (implicit) restriction regarding using dynamically sized (and inlined) types in CHT is that the _value field C++ object ends where the Node object ends, so there is not padding bytes where the dynamic payload is allocated. (effectively sizeof(VALUE) % alignof(Node) == 0 as long as there are no non-standard alignment fields in the Node metadata). I chose to test this as a runtime assert that the _value ends where the Node object ends, instead of a static assert with the alignment as it seemed to more explicitly show the intent of the check.

Running testing tier1-7


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-8332139: SymbolTableHash::Node allocations allocates twice the required memory (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 19214

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 13, 2024

👋 Welcome back aboldtch! 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 May 13, 2024

@xmas92 This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8332139: SymbolTableHash::Node allocations allocates twice the required memory

Reviewed-by: iwalulya

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 131 new commits pushed to the master branch:

  • 0a9d1f8: 8332749: Broken link in MemorySegment.Scope.html
  • c9a7b97: 8332829: [BACKOUT] C2: crash in compiled code because of dependency on removed range check CastIIs
  • 7fd9d6c: 8332340: Add JavacBench as a test case for CDS
  • 417d174: 8331348: Some incremental builds deposit files in the make directory
  • 303ac9f: 8332671: Logging for pretouching thread stacks shows wrong memory range
  • 90758f6: 8332808: Always set java.io.tmpdir to a suitable value in the build
  • e19a421: 8332720: ubsan: instanceKlass.cpp:3550:76: runtime error: member call on null pointer of type 'struct Array'
  • 2581935: 8332528: Generate code in SwitchBootstraps.generateTypeSwitch that require fewer adaptations
  • b890336: 8328083: degrade virtual thread support for GetObjectMonitorUsage
  • 4e6d851: 8325324: Implement JEP 477: Implicitly Declared Classes and Instance Main Methods (Third Preview)
  • ... and 121 more: https://git.openjdk.org/jdk/compare/5a8df4106ac5386eb72e874dcadf2b18defe27d8...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the rfr Pull request is ready for review label May 13, 2024
@openjdk
Copy link

openjdk bot commented May 13, 2024

@xmas92 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.

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label May 13, 2024
@mlbridge
Copy link

mlbridge bot commented May 13, 2024

Webrevs

Copy link
Member

@walulyai walulyai left a comment

Choose a reason for hiding this comment

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

LGTM!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org ready Pull request is ready to be integrated rfr Pull request is ready for review
2 participants