-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8358680: AOT cache creation fails: no strings should have been added #25816
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
base: master
Are you sure you want to change the base?
8358680: AOT cache creation fails: no strings should have been added #25816
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. |
@shipilev I copied the part of your JDK-8352042: [leyden] Parallel precompilation changes from the Leyden repo that implements |
/contributor add @shipilev |
@iklam |
Can something else add string to table between you get number and safe point? How you avoid that? |
Not that I am aware of. In testing, I added |
Here are all the subclasses of JavaThread:
StringDedupThread is disabled when dumping heap objects. And the other threads probably will either be inactive, or won't be doing anything that would result in string interning. I guess someone could use jcmd to connect to the JVM at the wrong time and that might upset the archive assembly process. But that would create far worse problems than the bug that we are trying to fix here. |
Well, I am rewriting that part in openjdk/leyden#79. I can give you a hunk on top of this PR that would do the same thing: use the |
Actually, I need #25409 in mainline first :) |
I can wait for that for JDK 26. If I want to fix for JDK 25, will the current fix be good enough? |
Would be nice to avoid divergence between JDK 25, JDK 26 and Leyden/premain. Anyhow, I now think this fix in incomplete. In premain, we use this I think we need to figure our when we dump the shared table. Maybe even shutdown the compiler right before going into CDS dump? See how |
No Java code is executing at this point (we are in the only thread that can run Java code). Is there still a possibility for new compile tasks to be added?
In Leyden, we run the AOT compiler after the CDS dumping has finished, so if we shut down the compiler we would have to restart it. |
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 have a couple of comments. Overall, the approach seems good.
|
||
// This flag will be cleared after intern table dumping has completed, so we can run the | ||
// compiler again (for future AOT method compilation, etc). | ||
DEBUG_ONLY(Atomic::release_store(&_disable_interning_during_cds_dump, 1)); |
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 atomics work with bool or is this a refcount ?
|
||
void CompileTask::wait_for_no_active_tasks() { | ||
MonitorLocker locker(CompileTaskAlloc_lock); | ||
while (_active_tasks > 0) { |
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.
Doesn't this have to have an Atomic::load() to make it re-read in the loop? Even though it's after we reacquire the lock.
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.
Not if _active_tasks
is only written whilst the same lock is held.
@@ -346,6 +348,10 @@ bool StringTable::has_work() { | |||
return Atomic::load_acquire(&_has_work); | |||
} | |||
|
|||
size_t StringTable::items_count() { |
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 there's a convention to make accessor functions that use acquire semantics to be named items_count_acquire().
I still dislike hooking up to compiler infrastructure to figure out if something is adding interned strings. I really, really dislike the divergence we would introduce with JDK 25 -> JDK 26 once a variant of JDK-8357473 lands in mainline. I cannot yet think of better solution though, let me think about it some more. At very least we need to get the sequencing of patches right... |
I thought your comment was for #25841 |
Background: when writing the string table in the AOT cache, we do this:
StringTable::lookup_shared()
in the production run.This bug happened because:
_items_count
This PR attempts to fix both issues.
Progress
Issue
Contributors
<[email protected]>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25816/head:pull/25816
$ git checkout pull/25816
Update a local copy of the PR:
$ git checkout pull/25816
$ git pull https://git.openjdk.org/jdk.git pull/25816/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25816
View PR using the GUI difftool:
$ git pr show -t 25816
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25816.diff
Using Webrev
Link to Webrev Comment