Repository navigation
Add UTF to String cache for reflection calls - #13311
Conversation
|
Opening this up for discussion @fjeremic @amicic @tajila @DanHeidinga Some points:
|
jclexception.c should be re-examined as we had previously done similar improvements there: openj9/runtime/jcl/common/jclexception.c Lines 219 to 226 in 2156b54 Reflection's interning of method names / signatures is worth checking as well |
|
It would be nice to have some visibility of the size. GC already reports this: Perhaps we add another attribute to this line for the total size of this cache just prior to a flush? VGC changes could be a separate PR, though. I would not mind aligning the flushing with string&monitor pruning (see scanMonitorLookupCaches, for example), rather then piggybacking on exclusive access . The cache is already somewhat visible to GC (for concurrent movement updates). |
|
Planned updates:
Possibly:
|
|
Generic signature is currently not interned - it will have to be if we want it to take advantage of the cache (which is going to allocate strings only with |
|
@amicic I've moved the freeing code into the GC (without verbose or trace support). Can you please have a look and tell me if I need to override it in RealtimeRootScanner? |
5555646 to
fbecd0e
Compare
|
I think I will update the code handling generic signatures to use the cache (and hence intern the String). I'm sure generic signatures are common enough these days to warrant the caching. After #13320 is merged I'll also commonize the (admittedly trivial) code that fills in the filename for Class objects. |
ab5ccaf to
aed268d
Compare
|
@tajila What are your feelings about the infinitely growing cache? I feel adding command line controls to this might be overdesigning, as the cache is freed every GC. If we later decide to treat the cache as a clearable root, we could add the controls then. |
|
Judging from this PR, it looks like the we are only populating the cache for things like method/field/class names for the purposes of reflection, stackwalking, etc. Based on this I think the risk ballooning native mem usage is low if the @dmitripivkine is there an easy way to collect metrics in the RootScanner code? As a defensive move we could track the size of the utfCache and add it to |
|
The verbose GC/trace has been discussed above as future work. |
78eb86e to
b203812
Compare
|
I believe this is ready to go once the question about tenuring filenames is resolved. |
Yea I think we should be consistent there and tenure I think we should also tenure |
|
Tenuring changes made. |
|
@pshipton What do I need to do to open a doc item for this? |
f9e322e to
0326786
Compare
|
jenkins test sanity,extended win jdk11 |
|
Create an issue at https://github.com/eclipse-openj9/openj9-docs and follow the template, and then create a PR to made the doc changes. The new options page needs to be added to mkdocs.yml |
|
Testing has passed. I'm going to undo a non-change (copyright only) now, but I suggest not bothering with retesting after. |
Maintain a cache of J9UTF8 pointers to the matching java String for use in reflection, StackWalker, etc. The cache is on by default and can be controlled on the command line via the -XX:[+|-]UTFCache options. Fixes: eclipse-openj9#13289 [ci skip] Signed-off-by: Graham Chapman <graham_chapman@ca.ibm.com>
|
@dmitripivkine @DanHeidinga any concerns? |
|
@gacholio We will also need this in the 0.29 branch |
|
I pushed it to the 0.29 branch, along with removing Unsafe.defineAnonymousClass() from jdk17, so we don't need to double deliver. |
|
Change appears responsible for some intermittent internal test failures, and may also show up in the public builds. I'm going to revert until it can be fixed. |
|
Can confirm that disabling the feature seems to make the problem go away. |
|
Testing the probable fix now. |
Maintain a cache of J9UTF8 pointers to the matching java String for use
in reflection, StackWalker, etc.
The cache is on by default and can be controlled on the command line via
the -XX:[+|-]UTFCache options.
Fixes: #13289
[ci skip]
Signed-off-by: Graham Chapman graham_chapman@ca.ibm.com