-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8338912: CDS: Segmented roots array #20858
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
8338912: CDS: Segmented roots array #20858
Conversation
👋 Welcome back shade! A progress list of the required criteria for merging this PR into |
@shipilev 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 112 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 |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the design is good. I have some suggestions for readability and simplification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just some nits on naming, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shipilev Glad to see this change. As mentioned in yesterday's premain meeting, we ran into the single roots array scalability issue trivially when experimenting with real world applications back in 2021. At the time, I reworked it to use a 'linked-roots-array' solution to accommodate a large number of roots. If the required size was larger than the limit, multiple 'roots' arrays were allocated. The last element in the current 'roots' array contained the next 'roots' array. The last element in the last 'roots' array was NULL. The multi-roots-array solution works with GC automatically, and resolves the scalability problem. Your segmented roots array change is in the same direction and is necessary to make CDS workable for real world usages.
Good to know this is not only the problem with our tests, but also a real-world issue!
Right, I actually started with something like this: an array of slices, like What we arrived here is basically |
I don't quite understand the Windows |
This kind of failure usually can be diagnosed by diffing the map files that are generated the test case. Let me try to reproduce it on my side. |
Hmm, since you haven't change the logic of how the archive is created, except that you move the allocation of the root array(s) from the end to the beginning of the heap objects, I think it's probably caused by this:
Maybe explicitly add an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Just two small nits.
Diff of the map files confirms this:
The 0x000001e2 is garbage. |
Whoa, that looks fragile! It feels safer to memset(0) the entire header then? Whack-a-mole-ing the alignment paddings every time we add a field is not convenient. |
Testing |
Hm, maybe I am misunderstanding this. I see there is the initialization here:
...and here we read the header in its entirety:
I'll look around map files to understand it better. |
memset the header first is not going to help. The random bits are added by this call:
Maybe you can add overload the assignment operator to copy the fields individually. This will stop VC++ from copying the garbage, so it will leave the unused slot in its original (zeroed) state. |
Hrmpf. I thought implicit copy constructors do this right. Apparently not. Let me try and define the explicit copy constructor + assignment operator... |
All right, I think this works. I believe we still explicitly default to trivial copy constructor + assignment operator, allow them to copy the entire representation, but we also make sure that representation has no garbage in its gaps. I am running this through our testing. @iklam, if you can run this through your tests, it would be helpful too. |
I ran bacc5d8 in our CI for tiers 1-4 and didn't see any regressions. |
Our testing passes here as well. I also changed I think we are done here. We need a second Reviewer, maybe @calvinccheung? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I have couple of minor suggestions.
I'm also running tiers 1 - 4 testing with your patch. Results look good so far.
Thanks for reviews! /integrate |
Going to push as commit dc00eb8.
Your commit was automatically rebased without conflicts. |
Attempt to drop the min region alignment with JDK-8337828 highlights an interesting trouble. The roots array we are creating during the dump time can easily be larger than the min region alignment. We are currently "lucky" none of our tests hit this limit. AFAICS, about 128K classes would be enough to hit the current 1M min region alignment. Dropping the min region alignment to 256K starts to fail the test with "only" 30K classes, JDK-8338856.
We can slice that heap root array, and thus untie the roots count from the min region alignment. I am submitting something that works, but this might not be the final form for it. I would like @iklam to poke holes in this approach :)
Additional testing:
runtime/cds
all
all
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/20858/head:pull/20858
$ git checkout pull/20858
Update a local copy of the PR:
$ git checkout pull/20858
$ git pull https://git.openjdk.org/jdk.git pull/20858/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 20858
View PR using the GUI difftool:
$ git pr show -t 20858
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/20858.diff
Webrev
Link to Webrev Comment