-
Couldn't load subscription status.
- Fork 6.1k
8347335: ZGC: Use limitless mark stack memory #23571
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
Conversation
|
👋 Welcome back eosterlund! A progress list of the required criteria for merging this PR into |
|
@fisk 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 4 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ 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.
As the old saying goes malloc's the limit. Or maybe it was the sky.
lgtm. Good work!
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!
Driveby review
Thanks Ivan! |
|
/integrate |
|
Going to push as commit 65f79c1.
Your commit was automatically rebased without conflicts. |
When ZGC performs marking, a lock-free data structure is used to keep track of objects that still need to be traced in the object traversal. This lock-free data structure uses versioned pointer as a technique to avoid ABA problems, prevalent when writing lock-free data structures. This required partitioning pointers in the structure to embed both a version and a location.
Due to the reduced addressability of locations with only a portion of the pointer bits, a special memory space was created to manage the data structure such that offsets could be encoded, instead of addresses.
Since the memory area needs to be contiguous, the JVM needs to know what the expected maximum size of this space will ever be, within some limiting bounds. That is what
-XX:ZMarkStackSpaceLimitcontrols.While this strategy has worked well in practice, the design does limit the scalability of ZGC, due to limits in how much contiguous memory can be encoded with a subset of the pointer bits. Not to mention that users have no idea what number to put in to this JVM option.
The
-XX:ZMarkStackSpaceLimitJVM option is needed due to using a contiguous allocator to solve an ABA problem in a lock-free data structure. By selecting another solution for the ABA problem, the need for the special contiguous memory allocator and hence the JVM option can be removed.This PR proposes a new solution for that original ABA problem in the lock-free data structure, which renders the entire machinery behind the
-XX:ZMarkStackSpaceLimitJVM option redundant. The proposed technique is to use hazard pointers instead.The use of hazard pointers is a well established safe memory reclamation (SMR) technique for writing lock-free data structures, that we also use in the Threads list. The main idea is to publish what pointer has been read with a hazard pointer, so that concurrent threads know not to free memory that is being concurrently used. Freeing of such racingly accessed memory is deferred until it is safe, hence solving the ABA problem. This also allows using plain malloc/free instead of a custom contiguous memory allocator for these structures.
Only popping nodes from the mark stacks requires hazard pointers, and only GC workers pop entries from the mark stacks. Therefore, hazard pointers may be stored in a per-worker variable.
I have measured throughput, latency, marking times and memory usage across a number of programs and platforms, and not seen any interesting changes in the behavior, other than having a more predictable and consistent native memory usage, instead of the slightly more temperamental behavior that we have today due to eagerly handing the mark stack memory back to the OS between GC cycles, while requiring it all back the next cycle.
With this change, another JVM option bites the dust. I have already gotten the CSR to obsolete the
-XX:ZMarkStackSpaceLimitJVM option approved (cf. https://bugs.openjdk.org/browse/JDK-8349204).Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23571/head:pull/23571$ git checkout pull/23571Update a local copy of the PR:
$ git checkout pull/23571$ git pull https://git.openjdk.org/jdk.git pull/23571/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23571View PR using the GUI difftool:
$ git pr show -t 23571Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23571.diff
Using Webrev
Link to Webrev Comment