<div class="__aliyun_email_body_block"><div  style="line-height:1.7;font-family:simsun;font-size:14.0px;color:#000000;"><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">Hi Roberto,</span></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;"><br ></span></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">Excited to hear the news about improving G1 barrier! I have a few questions about this proposal:</span></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;"><br ></span></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">    a)  ZGC uses late expansion because it has a clear fast path and a medium/slow path. The fastpath</span></div><div  style="clear:both;"><font  face="Tahoma, Arial, STHeiti, SimSun">contains only 1 or 2 simple instructions so doesn't need optimization from c2. G1 post barrier has several</font></div><div  style="clear:both;"><font  face="Tahoma, Arial, STHeiti, SimSun">branch check and doesn't have clear boudaries of fast or slow paths. And there could be optimization opportunity such</font></div><div  style="clear:both;"><font  face="Tahoma, Arial, STHeiti, SimSun">as <span >JDK-8225776. Permanently avoiding C2 optimization might lose performance.</span></font></div><div  style="clear:both;"><font  face="Tahoma, Arial, STHeiti, SimSun"><span ><br ></span></font></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">    b)  G1(as well as card table remset GC) uses imprecise card mark which marks the object address card instead of the field address.</span></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">If we use late expansion, we only have field address there and therefore have to recompute the object address which</span></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">needs additional instructions or registers. BTW, I didn't see the details in the prototype implementation. We can</span></div><div  style="clear:both;"><font  face="Tahoma, Arial, STHeiti, SimSun">alway use precise card mark in G1 anyway. </font><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;">Imprecise card mark has the advantage to eliminate redundant card</span></div><div  style="clear:both;"><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"> mark while writing into different field of an object</span><span  style="font-family:Tahoma,Arial,STHeiti,SimSun;"> because the card mark addresses are the same. Parallel GC can perform this optimization.</span></div><div  style="clear:both;"><font  face="Tahoma, Arial, STHeiti, SimSun"><br ></font></div><div  style="clear:both;"><font  face="Tahoma, Arial, STHeiti, SimSun">The late expansion could benifit from domination analysis to remove redudant barriers and traditional ideal optimization could barelly help</font></div><div  style="clear:both;"><font  face="Tahoma, Arial, STHeiti, SimSun">G1 barrier. Looking forwarding to your reply and progress!</font></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;"><br ></span></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">Thanks,</span></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">Liang</span></div><div  style="clear:both;"><span  style="color:#000000;font-family:Tahoma,Arial,STHeiti,SimSun;font-size:14.0px;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:.0px;text-transform:none;word-spacing:.0px;white-space:normal;background-color:#ffffff;text-decoration-thickness:initial;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline;">________________________________________</span></div><div  style="clear:both;">发件人: porters-dev <porters-dev-retn@openjdk.org> 代表 Roberto Castaneda Lozano<br >发送时间: 2024年2月2日 22:37<br >收件人: Andrew Dinn <adinn@redhat.com>; porters-dev@openjdk.org<br >主题: Re: [External] : Re: Heads-up: Late G1 Barrier Expansion (Draft JEP)<br ><br >Hi Andrew,<br ><br >Thanks for your interest! I am unfortunately not very familiar with Shenandoah and its barrier model, but in principle late barrier expansion should be applicable to any collector where barriers are tightly coupled to individual memory access operations and performance does not depend too much on exposing barrier operation details to the JIT compiler.<br ><br >If it helps, our prototype is available here: <a  href="https://github.com/robcasloz/jdk/tree/g1-late-barrier-expansion" target="_blank">https://github.com/robcasloz/jdk/tree/g1-late-barrier-expansion</a>. Please note that this is early, experimental work and might change significantly as the JEP evolves.<br ><br >Thanks,<br ><br >Roberto<br ><br >________________________________________<br >From: Andrew Dinn <adinn@redhat.com><br >Sent: Friday, February 2, 2024 2:33 PM<br >To: Roberto Castaneda Lozano; porters-dev@openjdk.org<br >Subject: [External] : Re: Heads-up: Late G1 Barrier Expansion (Draft JEP)<br ><br >Hi Roberto,<br ><br >On 02/02/2024 13:18, Roberto Castaneda Lozano wrote:<br >> I have written (together with Erik Österlund) a draft JEP for <br >> simplifying C2's handling of G1 barriers, see <br >> <a  href="https://bugs.openjdk.org/browse/JDK-8322295" target="_blank">https://bugs.openjdk.org/browse/JDK-8322295</a>. This is a heads-up that <br >> the implementation of this JEP requires platform-specific support from <br >> all OpenJDK ports. While interpreter G1 barrier implementations are <br >> available for all ports and can be largely reused, the JEP <br >> additionally requires 1) defining G1-specific ADL instructions and 2) <br >> implementing platform-specific logic to support runtime calls from the <br >> barrier code. For ports that already support ZGC, the effort should be <br >> smaller, as the logic for 2) can be shared between ZGC and G1.<br >><br >> To give a rough estimation of the required effort, the x86-64 changes <br >> in our prototype involve approximately 900 line insertions and 300 <br >> line deletions over 9 files, among which approximately 300 deleted and <br >> inserted lines correspond to logic factored out from ZGC.<br ><br >I looked at the proposal and was interested in the approach, not least because ZGC appears to have traversed the path that this JEP recommends<br >G1 to follow.<br ><br >Have you considered whether this same approach might be taken with the Shenandoah GC? Alternatively, can declare any basic assumptions regarding how G1 operates that are needed to enable this change which might therefore need be met by Shenandoah?<br ><br >Of course, access to the prototype code might help answer those questions (at least it would help someone better versed in Shenandoah than me) but a high-level summary of what in the design of G1 and ZGC makes this approach work or, conversely, might make it fail would, if available, be a great help.<br ><br >regards,<br ><br ><br >Andrew Dinn<br >-----------<br ><br >=</div><div  style="line-height:20.0px;clear:both;"><br ></div></div></div>