-
Notifications
You must be signed in to change notification settings - Fork 6.3k
8364929: Assign unique id to each AdapterBlob stored in AOTCodeCache #27553
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
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
👋 Welcome back asmehra! A progress list of the required criteria for merging this PR into |
@ashu-mehra 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 118 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 |
@ashu-mehra 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
|
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.
How you insure that the order of adapters generation is the same in assembly and production runs?
Adapters are not generated again in the production run. The adapter id is part of the AdapterHandlerEntry and they are stored in the AOTCache in the assembly run. In the production run when they are loaded back, we get the max id and use it populate the running id counter. Any new adapter generated in the production run gets the next id. Does that help? |
Do we have guarantee that we load AOT adapters before any new adapter is generated? Also if hash is not used we don't need related methods. Right? |
There is no check for that as such. The adapters are loaded in
Hash is still needed to look up an adapter in the runtime table based on the fingerprint obtained from method signature. |
Yes. Adapters can't be requested when |
max_id = MAX2(max_id, entry->id()); | ||
}); | ||
// Set adapter id to the maximum id found in the AOTCache | ||
_id_counter = max_id; |
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.
Is this number the same as number of AOT adapter entries in AdapterHandlerEntry? Do we need max_id
? In which case they could be different?
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.
Is this number the same as number of AOT adapter entries in AdapterHandlerEntry? Do we need max_id? In which case they could be different?
I thought about this. It is possible that some adapters generated in assembly phase are not stored in the cache. So there may be gaps in the adapter ids of the adapters in the cache. In such case using the number of entries to decide next adapter id can result in clash of adapter id with the runtime generated adapters. But the maximum id ensures adapter ids are never reused.
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.
Please add comment about that.
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.
Done
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.
Now only assert(_id_counter ==0) is missing.
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.
Added the assert before _id_counter = max_id
AOT stored handlers to initialize _id_counter Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
if (id == 0) { | ||
// id_counter overflow | ||
return nullptr; | ||
} |
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 it will cause issue with ubsan
because we don't check for nullptr
returned from this method.
May be use guarantee(id > 0);
instead ?
2^32 -1 is big number. We can't have so much method's signatures combinations.
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.
Done
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
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 a couple of nits.
AdapterHandlerEntry* AdapterHandlerLibrary::new_entry(AdapterFingerPrint* fingerprint) { | ||
return AdapterHandlerEntry::allocate(fingerprint); | ||
uint id = (uint)AtomicAccess::add((int*)&_id_counter, 1); | ||
guarantee(id > 0, "id_counter overflow"); |
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 we can even change this to an assert. We limit the AOT metaspace size to UnscaledClassSpaceMax
which is 4GB.
All AOT methods would have to live within the AOT metaspace , so we will have much fewer than 2^32 methods, which means will we have much fewer than 2^32 signatures. So the id
will never overflow. Maybe change this to:
assert(id > 0, "we can never overflow because AOT cache cannot contain more than 2^32 methods");
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.
Changed it to assert as suggested
static const int ENTRIES_COUNT = 4; | ||
|
||
private: | ||
uint _id; |
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.
This can be moved near _linked
so it can fit in the existing unused padding.
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.
Good point. Done.
Signed-off-by: Ashutosh Mehra <asmehra@redhat.com>
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.
Good.
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.
LGTM
/integrate |
Going to push as commit f62b9ec.
Your commit was automatically rebased without conflicts. |
@ashu-mehra Pushed as commit f62b9ec. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This patch assigns unique id to each AdapterHandlerEntry so as to avoid using hash computed from AdapterFingerPrint which may not be unique. Unique id allows AOTCodeCache to locate the AdapterBlob being requested to be loaded.
Testing:
Before this patch
runtime/cds/appcds/aotClassLinking/StringConcatStress.java
emits warning messages in the production run:With this patch, such warnings are not seen at all
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27553/head:pull/27553
$ git checkout pull/27553
Update a local copy of the PR:
$ git checkout pull/27553
$ git pull https://git.openjdk.org/jdk.git pull/27553/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27553
View PR using the GUI difftool:
$ git pr show -t 27553
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27553.diff
Using Webrev
Link to Webrev Comment