Implement KnownObjectTable caching#23012
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.
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.
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.
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. |
|
Win failure can't be related since it's not a jitserver test. |
The functionality of addKnownObjectConstraints() was disabled for JITServer due to the large number of messages it generates to retrieve information related to "known objects". This problem has been solved to a large extent in OpenJ9 through the addition of caching (see eclipse-openj9/openj9#23012). This commit re-enables addKnownObjectConstraints() for JITServer. Signed-off-by: Marius Pirvu <[email protected]>
The functionality of addKnownObjectConstraints() was disabled for JITServer due to the large number of messages it generates to retrieve information related to "known objects". This problem has been solved to a large extent in OpenJ9 through the addition of caching (see eclipse-openj9/openj9#23012). This commit re-enables addKnownObjectConstraints() for JITServer. Signed-off-by: Marius Pirvu <[email protected]>
OpenJ9 PR eclipse-openj9#23012 and omr PRs eclipse-omr/omr#8056 and eclipse-omr/omr#8062 implemented caching for the knownObjectTable. This PR performs the code cleanup removing unused data structures and functions. Signed-off-by: Marius Pirvu <[email protected]>
This commit builds on top of eclipse-openj9#23012 which has extended a KnownObjectTable entry to include additional information populated on demand. In this commit the additional information is populated eagerly when a new entry is added to the table as a result of a getOrCreateIndexAt() call. On AcmeAir benchmark this commit reduces the number of VM_getObjectClassInfoFromKnotIndex by an order of magnitude. The average number of messages per compilation is reduced by 4%. Signed-off-by: Marius Pirvu <[email protected]>
PR eclipse-openj9#23012 extended the entries of the Known Object Table (KNOT) to cache additional information related to known objects. PR eclipse-openj9#23163 populates this caches information eagerly. However, when the class of the known object is java/lang/Class we need to change the _clazz field of the KNOT entry to the class that the java/lang/Class object represents. Signed-off-by: Marius Pirvu <[email protected]>
The functionality of addKnownObjectConstraints() was disabled for JITServer due to the large number of messages it generates to retrieve information related to "known objects". This problem has been solved to a large extent in OpenJ9 through the addition of caching (see eclipse-openj9/openj9#23012). This commit re-enables addKnownObjectConstraints() for JITServer. Signed-off-by: Marius Pirvu <[email protected]>
OpenJ9 PR eclipse-openj9#23012 and omr PRs eclipse-omr/omr#8056 and eclipse-omr/omr#8062 implemented caching for the knownObjectTable. This PR performs the code cleanup removing unused data structures and functions. Signed-off-by: Marius Pirvu <[email protected]>
This commit builds on top of eclipse-openj9#23012 which has extended a KnownObjectTable entry to include additional information populated on demand. In this commit the additional information is populated eagerly when a new entry is added to the table as a result of a getOrCreateIndexAt() call. On AcmeAir benchmark this commit reduces the number of VM_getObjectClassInfoFromKnotIndex by an order of magnitude. The average number of messages per compilation is reduced by 4%. Signed-off-by: Marius Pirvu <[email protected]>
PR eclipse-openj9#23012 extended the entries of the Known Object Table (KNOT) to cache additional information related to known objects. PR eclipse-openj9#23163 populates this caches information eagerly. However, when the class of the known object is java/lang/Class we need to change the _clazz field of the KNOT entry to the class that the java/lang/Class object represents. Signed-off-by: Marius Pirvu <[email protected]>
This PR is mainly for the benefit of JITServer.
Experiments have shown 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