8379415: Contended classes can leave unused alignment padding#30117
8379415: Contended classes can leave unused alignment padding#30117caspernorrbin wants to merge 7 commits intoopenjdk:masterfrom
Conversation
|
👋 Welcome back cnorrbin! A progress list of the required criteria for merging this PR into |
|
@caspernorrbin 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: 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 20 new commits pushed to the
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 |
|
@caspernorrbin The following label will be automatically applied to this pull request:
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. |
Webrevs
|
coleenp
left a comment
There was a problem hiding this comment.
I think this looks good, but can you write a small test case?
I created a new test |
|
@liach Thank you for the test feedback! I've made the changes suggested. |
| failures += 1; | ||
| } | ||
|
|
||
| if (!arePaddedPairwise(Test3.class, "long1", "int1") || |
There was a problem hiding this comment.
I wonder if you could move these tests into the Test class as a static method like:
failures += Test2.checkLayout();
Then they'd be with the fields themselves.
There was a problem hiding this comment.
I've moved the layout checks to now be inside each class!
|
Thank you everyone for reviewing! /integrate |
|
Going to push as commit 4d7c139.
Your commit was automatically rebased without conflicts. |
|
@caspernorrbin Pushed as commit 4d7c139. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Hi everyone,
When placing fields, if the first field we place needs alignment, we insert extra padding before it. If the class is a contended class, or the field is part of a contended group, this inserted alignment block can become effectively lost and cannot be reused for another field, wasting space.
This happens in
FieldLayoutBuilder::compute_regular_layoutwhen we insert a field that needs alignment inside a contended range.First, we insert the padding. The structure then looks like this:
If we then insert an 8-byte
long, we need to align before inserting it. After inserting the field, the structure looks like this:At this point, because the start block is also the end block, we never look past it. As a result, we never see the 4-byte alignment block when continuing to place the remaining fields, even though it could be reused.
For contended classes and contended field groups, we need to ensure we search the whole contended range for empty blocks instead of stopping early. The code change is slightly different between the two cases, but both ensure we scan the full contended range so alignment padding can be reused.
Testing:
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/30117/head:pull/30117$ git checkout pull/30117Update a local copy of the PR:
$ git checkout pull/30117$ git pull https://git.openjdk.org/jdk.git pull/30117/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 30117View PR using the GUI difftool:
$ git pr show -t 30117Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/30117.diff
Using Webrev
Link to Webrev Comment