-
Notifications
You must be signed in to change notification settings - Fork 776
Implement KnownObjectTable caching #23012
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?
Conversation
|
@jdmpapin Could you please review this PR? There will be a follow up omr PR to actually use all this infrastructure. Thanks |
|
FYI @vijaysun-omr. |
dsouzai
left a comment
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.
Overall LGTM, minor deduplication requested.
runtime/compiler/env/VMJ9.cpp
Outdated
| retrievedObjInfo._jniReference = existingObjInfo._jniReference; | ||
| retrievedObjInfo._clazz = getObjectClass(objectReference); | ||
| retrievedObjInfo._isString = isString(retrievedObjInfo._clazz); | ||
| retrievedObjInfo._jlClass = getClassClassPointer(retrievedObjInfo._clazz); |
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 don't think we should really need to store _jlClass for every known object. It doesn't really meaningfully depend on the _clazz here. getClassClassPointer() just needs any old class so that it can find an instance of java/lang/Class. I understand though that VP needs to know whether we had it at this point. (It's pretty ridiculous that we can't just always guarantee that the JIT knows what it is... Maybe that could change, but let's set that aside.)
Reading on a bit, the values we determine here and the "FixedClass constraint" comment seem unnecessarily VP-specific.
It seems like all we should really need is _jniReference, _clazz, and the result of getClassFromJavaLangClass() (if appropriate), which we could call e.g. _reflectiveClass. The other logic could move (back) to VP:
- VP can call
getClassClassPointer()separately. The pointer is cached on the server. - VP can call
isString()separately. Thejava/lang/Stringclass pointer is also cached on the server. - The
_isFixedJavaLangClassvalue is just the result of a pointer comparison.
Then VP could use the value from either _clazz or _reflectiveClass as needed. This would also prevent VP-isms from sneaking into potential uses of this API elsewhere, e.g. finding out which class a known object represents in vector API expansion. We would have to contend though with getClassClassPointer() starting to succeed at different times 😞 For example, maybe it fails here, so then we don't set _reflectiveClass, but then it succeeds later in VP.
What do you think?
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.
It makes sense to reduce the number of fields that are cached as much as possible. Since this will require more testing my plan is to merge this PR ASAP, backport to upcoming release v0.57.0 (deadline on 2025/12/09), and immediately open another PR with proposed solution, but deliver just to master (dev) branch.
This commit is mainly for the benefit of JITServer.
Experiments have shows that addKnownObjectConstraints() function used
by GlobalVP generates many server-client messages when calling:
fej9()->getObjectClassInfoFromObjectReferenceLocation() to fetch
some class information about a particular known object.
This commit implements a caching mechanism for that class information as described below:
An entry in the knownObjectTable is extended to include the following fields:
uintptr_t *_jniReference; // This existed before this commit
TR_OpaqueClassBlock *_clazz;
TR_OpaqueClassBlock *_jlClass;
bool _isFixedJavaLangClass;
bool _isString;
When a new entry is added into the knownObjectTable, only the
"old" field _jniReference will be populated; the others will
be set to default values, NULL or false.
If GlobalVP is asking about the other fields and they are not
yet populated, the server will send a message, find the value
of these other fields and store them into the knownObjectTable.
If these fields are already populated when GlobalVP asks about
them, they will be immediately retrieved from the
knownObjectTable entry, saving a message.
Note that the same caching mechanism is going to be used at
the client, but the benefit is expected to be low.
Experimental results have shown a 84% reduction of the messages
sent by the server during addKnownObjectConstraints().
There are two options that control this feature:
-Xjit:disableKnownObjectTableCaching disables the caching
mechanism and always asks the client for the desired information.
-Xjit:enableKnownObjectTableCachingVerification when caching is
enabled this option always sends a message to the client,
fetches the desired information and then compares it against
the cached information. If the two don't match, a fatal assert is
triggered.
Depends on: eclipse-omr/omr#8056
Signed-off-by: Marius Pirvu <[email protected]>
|
I have addressed most of code review suggestions in the forced push 1981e13 |
|
jenkins test sanity all jdk21 |
|
On ppcle there is a timeout for one of the CRIU tests: On windows there are exceptions during jdk_vector_double128_j9_0 |
|
A small grinder for the plinux criu problem passed. |
This PR is mainly for the benefit of JITServer.
Experiments have shows that
addKnownObjectConstraints()function used by GlobalVP generates many server-client messageswhen calling:
fej9()->getObjectClassInfoFromObjectReferenceLocation()to fetch some class information about a particular known object.This commit implements a caching mechanism for that class information as described below:
An entry in the knownObjectTable is extended to include the following
fields:
When a new entry is added into the knownObjectTable only the "old" field
_jniReferencewill be populated; the others will be set to default values, NULL or false.If GlobalVP is asking about the other fields and they are not yet populated, the server will send a message, find the value of these other fields and store them into the knownObjectTable. If these fields are already populated when GlobalVP asks about them, they will be immediately retrieved from the knownObjectTable entry, saving a message.
Note that the same caching mechanism is going to be used at the client, but the benefit is expected to be low.
Experimental results have shown a 84% reduction of the messages sent by the server during
addKnownObjectConstraints().Note that in the future we may consider populating all fields of the knownObjectTable entry when that entry is added to the table.
This approach can eliminate all messages sent during
addKnownObjectConstraints()but may create additional overhead for filling up fields that the server may never use.There are two options that control this feature:
-Xjit:disableKnownObjectTableCachingdisables the caching mechanism and always asks the client for the desired information.-Xjit:enableKnownObjectTableCachingVerificationwhen caching is enabled this option always sends a message to the client, fetches the desired information and then compares it against the cached information. If the two don't match, a fatal assert is triggered.A follow on
addKnownObjectConstraints()change in omr will actually make use of this infrastructure.Depends on: eclipse-omr/omr#8056