-
Notifications
You must be signed in to change notification settings - Fork 721
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
Support non-tenured objects in the constantpool #7486
Comments
@LinHu2016 Would you please update code to scan all types of elements in CP in Scavenger for Java 11? Also would you please do general performance measure to know what cost of CP iteration is for Scavenger? |
@dmitripivkine Sure. |
I have done code update in GC, the performance comparison uses java 8 version(using Xgc option to enable/disable scanning CP object in scavenger) to run SPECjbb2015 preset compsite under regular gencon mode and concurrent scavenge mode. |
@LinHu2016 Is that scanning all CPs for every class in every scavenge? Or only those that have a young-gen object in the CP? |
@DanHeidinga we iterate all CPs for every class in every scavenge, but only nursery object in the CP might be copied. for test case there is no cp object in nursery. |
@vijaysun-omr @amicic @DanHeidinga Currently Scavenger does not scan Classes related metadata (except Class Statics). It is possible because all other class related objects must be allocated in Tenure mandatory. However we can not keep this behaviour any more. Condy code require to scan Class Constant Pool (already implemented for Java 11). Also VM developers requested Class Constant Pool scan for MH improvements (for Java 8 and Java 11 both). An enabling of scan of full Classes related metadata caused a regression in Scavenge time "2% regression on scavenge pause for gencon mode, 6.25% regression for concurrent scavenge" #7636 (comment) So I am proposing:
May I have your opinions please? |
The 2% regression to scavenger pauses on gencon doesn't really concern me given this would be hard to notice in the existing pause times. The 6.25% for concurrent scavenger is more of an issue as concurrent scavenger is aimed at low pause scenarios. I'm on board with this plan provided that we start work on the "Class needs to be scanned in Scavenger" flag immediately. |
Are the slowdowns in scavenge time reported in #7636 (comment) expected to be the norm ? Or is it the results from one benchmark that was tried ? Otherwise I agree with the plan mentioned by @dmitripivkine and echo Dan's comment that the CS overhead is the more worrisome one. |
This is result for SpecJBB 2015 (which is shows average behaviour usually). It is possible to construct test case where impact would be more significant obviously. However as far as we need this functionality so let focus on improvement part. @DanHeidinga @vijaysun-omr Thank you for comments |
@dmitripivkine Sure. |
The optimization is already there. In Scavenger, we historically scanned only static slots only for classes that had statics to Nursery. This was accomplished by remembering such classes through static barrier (J9WriteBarrierJ9ClassStore or appropriate jit wrapper) call after the store itself. [The underlying mechanism was using the class object (that is known to be pre-tenured) to remember/add to the same RememberSet used for standard object Tenure->Nursery references] #7636 will widen the scope of what we scan within a class, if a class is to be scanned. But decision logic whether to scan a class (based on whether it's in RS) is already there and unaffected. We, of course, have to make sure that all other class slot stores indeed use the WB API after the store. (I'm only seeing a couple of sites that use it!?) |
All writes to the constantpool should be occurring in resolvesupport.cpp using the Taking a quick look at it shows all the places I would expect are using the |
J9STATIC_OBJECT_STORE will do it (it will do both the store and than call the barrier above) and actually preferred (to me) from separating the store and barrier calls. But, all recently added slots (MH, MT, CD...) should comply, too. |
J9Class->callSites is updated using the CAS barrier: https://github.com/eclipse/openj9/blob/66556b4a095d62b0a37915c1793a5e697f6237e8/runtime/vm/resolvesupport.cpp#L2139 J9Class->MethodTypes as used for J9Class->varHandleMethodTypes as used for VarHandle invokes: ConstantDynamic updates to the CP: And the "regular" CP updates use Anything I've missed here? |
All those look ok. In a few min manually scanning the class code I could not find any missed. Btw, what about Java_java_lang_invoke_MethodType_makeTenured? I don't see it is used (return value ever stored anywhere). And while on the topic of barriers, we need to track reads as well (which I had mentioned before). I believe most are missed like: There are the key for enabling concurrent class scanning in CS. |
Interning of MethodTypes is handled in Java but only tenured objects can be interned in that table as they end up in the constantpool. The makeTenured() calls are only done when interning: All of this code will go away once the CPs are scanned during all scavenges.
That's going to be a major change as the BytecodeInterpreter and other code (likely lots of it) reads CP entries without read barriers today.
Can the "Support non-tenured objects in the constantpool" be completed without enabling concurrent class scanning in CS? Or do the two have to land at the same time? |
Enabling concurrent class scanning in CS is not strictly a pre-req for this work. It's an independent work item/optimization that will compensate the increase of class scanning time introduced by this work. At some point (when only statics where part of Scavenge class scanning) we were very close to enabling it, but then came CP scanning which complied only with static stores barriers but not with static reads (which as I said are pre-req for enabling concurrent class scanning). And now, we are adding even more to class scanning (that also does not comply with read barriers) and making this optimization even harder to happen. Anyhow, I just want to raise awareness of it, rather than holding completion of this or other work. |
I opened #7718 to record the CS work that needs to be done in the future. |
JDK 11 introduced ConstantDynamic which allowed user allocated objects to be installed in classes ConstantPools (CP). This required changes to the GC so that the scavenges would scan the CP of classes with ConstantDynamics.
Our current JSR 292 implementation forces MethodType and MethodHandle objects that are stored into the CP to be tenured. Given we have the capability to scan CPs in scavenges, it would be good to remove the special case code to tenure MT & MH.
This also is an enabler for the investigation work in #7352 (Use OpenJDK LambdaForm MH implementation) as it makes it easier to consume the OpenJDK classes without patches.
Ideally, the existing store barriers would be sufficient to mark the classes as having CP entries that are in the young gen.
The existing special handling for Condy can be seen in https://github.com/eclipse/openj9/blob/master/runtime/gc_structs/ConstantPoolObjectSlotIterator.cpp
If we need to do special casing, then the following cases would need special handling:
J9CPTYPE_METHOD_TYPE
J9CPTYPE_METHODHANDLE
J9CPTYPE_CONSTANT_DYNAMIC
Additionally, for classes loaded by Unsafe.defineAnonymousClass() and using constantpool patching, we would also need to scan
J9CPTYPE_STRING
as they can be used to "smuggle" other objects into the CP.The text was updated successfully, but these errors were encountered: