-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8342283: CDS cannot handle a large number of classes #21797
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
8342283: CDS cannot handle a large number of classes #21797
Conversation
|
👋 Welcome back iklam! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
As has been discussed elsewhere, this is an unusual but legitimate use of In the case of the AOT cache, the VM compiler does not constant fold stable vars when creating AOT code at cache assembly. With this "fine print", we see that stable vars are allowed to be rather unstable in the assembly phase, as long as they stabilize before the VM compiler starts compiling JIT code in the production run. I suppose this should be written out better, for maintainers of code which uses stable vars. |
| // Note: VM also uses this field to decide if the current class loader | ||
| // is parallel capable and the appropriate lock object for class loading. | ||
| private final ConcurrentHashMap<String, Object> parallelLockMap; | ||
| private @Stable ConcurrentHashMap<String, Object> parallelLockMap; |
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.
When we reworked memory barriers for @Stable fields (JDK-8333791), we had a discussion on memory model implications of @Stable. There were competing proposals, but we have settled on "@Stable behave like final-s, in order to provide safety margin for uses where we accidentally rely on this property for some final-like fields". This change introduces such the "accident", AFAICS.
| * @implNote This is done while the JVM is running in single-threaded mode, | ||
| * and at the very end of Java bytecode execution. We know that no more classes | ||
| * will be loaded and none of the fields modified by this method will be used again. |
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 wonder if moving all this to VM side, which is not bound to Java language rules, would be conceptually cleaner. It would be more work, but I think there any only three classes that implement resetArchivedStates, which limits the scope of the change. I am prototyping this locally...
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.
Something like this: master...shipilev:jdk:JDK-8342283-cds-reset-archived-states. This passes runtime/cds at least.
…valent method for ConcurrentHashMap, though
|
@iklam This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
@iklam This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
When lots of classes are loaded during
java -Xshare:dump, the internal arrays used by some of the HashMaps and ArrayLists become too large to be archived by CDS (> 256KB).At the very end of Java bytecode execution during
java -Xshare:dump, we used to callclear()on these tables to free their elements (*) -- these tables are repopulated at run time when classes are loaded incrementally. However, theclear()call doesn't resize the internal arrays.The fix is to re-ininitialize these tables to new, empty tables that have small internal arrays.
===
(*) the call to
resetArchivedStates()is made from HeapShared::reset_archived_object_states()Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21797/head:pull/21797$ git checkout pull/21797Update a local copy of the PR:
$ git checkout pull/21797$ git pull https://git.openjdk.org/jdk.git pull/21797/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21797View PR using the GUI difftool:
$ git pr show -t 21797Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21797.diff
Using Webrev
Link to Webrev Comment