<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.m4157850829767933887apple-converted-space
        {mso-style-name:m_4157850829767933887apple-converted-space;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Ashutosh,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks a lot for your response. I checked the wiki but it did not contain details, so had to take a look into source code.<o:p></o:p></p>
<p class="MsoNormal">Plus, I noticed one thing – Wiki mentions that degenerated STW GC continues concurrent cycle, while checking code shows that logic is more complex:<o:p></o:p></p>
<p class="MsoNormal"><a href="https://github.com/openjdk/jdk/blob/master/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp#L134">https://github.com/openjdk/jdk/blob/master/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp#L134</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks again.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Regards,<o:p></o:p></p>
<p class="MsoNormal">Alex Dubrouski<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">Ashutosh Mehra <asmehra@redhat.com><br>
<b>Date: </b>Tuesday, November 22, 2022 at 9:14 AM<br>
<b>To: </b>Alex Dubrouski <adubrouski@linkedin.com><br>
<b>Cc: </b>"shenandoah-dev@openjdk.org" <shenandoah-dev@openjdk.org><br>
<b>Subject: </b>Re: Allocation pacing and graceful degradation in ShenandoahGC<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Hi Alex,<o:p></o:p></p>
<div>
<p class="MsoNormal">I have spent some time understanding the Shenandoah Pacer and I will try to answer your questions as best I can.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="color:black">Does that mean that each Java thread goes throw runtime -> heap to allocate, and that's how pacer paces it? So we just pace any allocating thread and threads that allocate more will just hit this code more often.</span><span style="color:#500050"><o:p></o:p></span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="color:#500050"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal">Allocations from tlab do not go through pacer, but allocating a new tlab does go through the pacer.  And yes a thread allocating more is more likely to hit the pacer. <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#500050"><o:p> </o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="color:black">so I assume if there is no budget available it will pace a thread for up to 10ms, but it does not imply allocation failure.</span><span style="color:#500050"><o:p></o:p></span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="color:#500050"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal">Yes, it does not imply allocation failure. It is just a mechanism to ensure concurrent gc is able to keep pace with the allocation rate.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#500050"><o:p> </o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="color:#500050"> </span><span style="color:black">Heap class tries to allocate under lock and if unsuccessful considers this as allocation failure and handles it by calling ShenandoahControlThread. Does it mean that Pacer can’t
 cause GC to switch to degenerated mode or I am missing something?</span><span style="color:#500050"><o:p></o:p></span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="color:#500050"><o:p> </o:p></span></p>
</div>
<p class="MsoNormal">Pacer itself does not cause GC to degenerate. It only delays the mutator thread. As you mentioned earlier, after the expiry of wait time the mutator thread would still attempt allocation which may succeed.<br>
If the allocation rate is high, pacer may not be able to cope up, and in that case the mutator thread may suffer allocation failure which would result in running a degenerated GC cycle.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="color:black"> If Pacer doesn't have budget to allocate memory it paces thread, but is there any global budget for pacing time or it is only per thread max (ShenandoahPacingMaxDelay)? </span><span style="color:#500050"><o:p></o:p></span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="color:#500050"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal">The wait time introduced by Pacer is per thread and bounded by ShenandoahPacingMaxDelay. I don't think there is any global budget for pacing time.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="color:#500050"><o:p> </o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal"><span style="color:black">It would really nice if you can sched some light on these transitions: Concurrent Mode -> Pacing (single thread and total pacing time for all threads) -> most importantly logic of transitioning from pacing to degenerated
 GC</span><span style="color:#500050"><o:p></o:p></span></p>
</blockquote>
<div>
<p class="MsoNormal"><span style="color:#500050"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal">I will try to summarize the transition to degenerated GC.<o:p></o:p></p>
</div>
<p class="MsoNormal">Allocation failures are signaled by the mutator thread by setting a flag _alloc_failure_gc [0] in ShenandoahControlThread::handle_alloc_failure() and then it waits on _alloc_failure_waiters_lock [1] for notification from the control thread <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">after it has handled the allocation failure.<br>
The control thread executing run_service() checks if the flag _alloc_failure_gc is set [2], if so it indicates a pending allocation failure. It then tries to handle alloc failure by running either a Degenerated GC or a Full GC cycle. That decision depends on
 ShenandoahHeuristics::should_degenerate_cycle() which performs a simple counter check for the number of consecutive degenerated GC cycles.<o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">There are some details in the wiki [4] for pacing and degenerated gc in case you have not looked at that.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I hope this helps you to move forward in your effort.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">[0] <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblob%2Ffba763f82528d2825831a26b4ae4e090c602208f%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahControlThread.cpp%23L531&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421521483%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=cmRF%2F%2FFwQIVUoLAHjQs7HuhLBgEDyvV100UQWjon3pc%3D&reserved=0" target="_blank">https://github.com/openjdk/jdk/blob/fba763f82528d2825831a26b4ae4e090c602208f/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp#L531</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">[1] <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblob%2Ffba763f82528d2825831a26b4ae4e090c602208f%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahControlThread.cpp%23L543&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=JfLvsngY6UyLiR%2F5MWjcQA%2Bl8WTevoiAe8lK1072MYc%3D&reserved=0" target="_blank">https://github.com/openjdk/jdk/blob/fba763f82528d2825831a26b4ae4e090c602208f/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp#L543</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">[2] <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblob%2Ffba763f82528d2825831a26b4ae4e090c602208f%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahControlThread.cpp%23L100&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=yRea2fdAzXYhr2azE9KoCwOMQNlRterUn05xP45RcdY%3D&reserved=0" target="_blank">https://github.com/openjdk/jdk/blob/fba763f82528d2825831a26b4ae4e090c602208f/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp#L100</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">[3] <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblob%2Ffba763f82528d2825831a26b4ae4e090c602208f%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahControlThread.cpp%23L127&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=nvt4GJ4Rq%2FY2wOVBwt6nqYCAoz%2F4UWjkW613jZDz2qo%3D&reserved=0" target="_blank">https://github.com/openjdk/jdk/blob/fba763f82528d2825831a26b4ae4e090c602208f/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp#L127</a><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">[4] <a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwiki.openjdk.org%2Fdisplay%2Fshenandoah%2FMain&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=X6XKEvWm%2FMtY%2FQ9uDsKkc05YD3IeUevDYgXSsWyWtME%3D&reserved=0" target="_blank">https://wiki.openjdk.org/display/shenandoah/Main</a><o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Ashutosh Mehra<o:p></o:p></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Mon, Nov 14, 2022 at 4:07 PM Alex Dubrouski <<a href="mailto:adubrouski@linkedin.com">adubrouski@linkedin.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">Good afternoon everyone,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="color:black">I checked all video presentations and slides by Alex Shipilev and Roman Kennke about ShenandoahGC to find the answer for my question with no luck. I am
 trying to find more details about transitions between modes in ShenandoahGC</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">I am looking for solution to assess concurrent collector health in real time using different metrics.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">Here is the schema of transitions, and allocation failure causes degenerated GC cycle, but it does not mention allocation pacing at all:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblob%2Ffba763f82528d2825831a26b4ae4e090c602208f%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahControlThread.cpp%23L361&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=syJBev7PZMNFYU5y9vQhQpJqZCZzFcyg0j9aniS%2BExg%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blob/fba763f82528d2825831a26b4ae4e090c602208f/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp#L361"><span style="color:#0563C1">https://github.com/openjdk/jdk/blob/fba763f82528d2825831a26b4ae4e090c602208f/src/hotspot/share/gc/shenandoah/shenandoahControlThread.cpp#L361</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">I tried to dig further into this logic, but need your help to put all the pieces together</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">I was not able to effectively trace entry point, but this might work, allocation on heap outside of TLAB:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblob%2Fmaster%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshared%2FmemAllocator.cpp%23L258&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Rp4PwOJSLF%2F11u3O5pbdVb5qbVQIP%2FfQX4sTwJft4dc%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blob/master/src/hotspot/share/gc/shared/memAllocator.cpp#L258"><span style="color:#0563C1">https://github.com/openjdk/jdk/blob/master/src/hotspot/share/gc/shared/memAllocator.cpp#L258</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">in case of ShenandoahGC I assume we call</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblame%2F739769c8fc4b496f08a92225a12d07414537b6c0%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahHeap.cpp%23L901&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=yEcGmHjCW%2Bkai2Zenmn%2BUwvtsuNH0CC9AiNZUOGMXkQ%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blame/739769c8fc4b496f08a92225a12d07414537b6c0/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp#L901"><span style="color:#0563C1">https://github.com/openjdk/jdk/blame/739769c8fc4b496f08a92225a12d07414537b6c0/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp#L901</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">which then calls</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblame%2F739769c8fc4b496f08a92225a12d07414537b6c0%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahHeap.cpp%23L821&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1rtA5PwKkWXJjczTw0AfGr8Ac1zCELNdz%2F%2B29gB3SMg%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blame/739769c8fc4b496f08a92225a12d07414537b6c0/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp#L821"><span style="color:#0563C1">https://github.com/openjdk/jdk/blame/739769c8fc4b496f08a92225a12d07414537b6c0/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp#L821</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">if mutator is allocating and pacer enabled (default) we enter Pacer:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblame%2F739769c8fc4b496f08a92225a12d07414537b6c0%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahHeap.cpp%23L828&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Usi%2FYvLHmn9XHCPrgEsPKjzEi0midxwFlG80b%2Fbg9Z4%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blame/739769c8fc4b496f08a92225a12d07414537b6c0/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp#L828"><span style="color:#0563C1">https://github.com/openjdk/jdk/blame/739769c8fc4b496f08a92225a12d07414537b6c0/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp#L828</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblame%2Fmaster%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahPacer.cpp%23L229&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=MVBpmjH64QjLsV0IuJFWvvlUQ2v5WFrSSh49FQByhH0%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blame/master/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp#L229"><span style="color:#0563C1">https://github.com/openjdk/jdk/blame/master/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp#L229</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">and I assume try to handle it nicely, if not we start pacing:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblame%2Fmaster%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahPacer.cpp%23L253&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=PjRH5PIijsSGcKYTsF%2BjBmrF6i1LdfVKT0tjvvloh3c%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blame/master/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp#L253"><span style="color:#0563C1">https://github.com/openjdk/jdk/blame/master/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp#L253</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">I have few questions here:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">- Could you please explain a bit how the system of taxes works?  I assume mutators claim budget, while GC replenishes it async, but the details are missing and no comments in the code</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">- To pace we use wait function from Monitor class</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblame%2Fmaster%2Fsrc%2Fhotspot%2Fshare%2Fruntime%2Fmutex.cpp%23L232&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=is4CcL21QgK8N8ucoDZlPS8q%2FUj6RxAVfEryn375nFs%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blame/master/src/hotspot/share/runtime/mutex.cpp#L232"><span style="color:#0563C1">https://github.com/openjdk/jdk/blame/master/src/hotspot/share/runtime/mutex.cpp#L232</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">  but the first thing it gets current Java thread. Does that mean that each Java thread goes throw runtime -> heap to allocate, and that's how pacer paces it? So we just pace any allocating thread and threads that allocate more will
 just hit this code more often.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">- Pacer uses ShenandoahPacingMaxDelay (10ms) as max, but pace_for_allocation returns void<span class="m4157850829767933887apple-converted-space"> </span></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblob%2Ffba763f82528d2825831a26b4ae4e090c602208f%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahHeap.cpp%23L826&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=e7SMAWcJTgZm8s%2FWgBPu1H9RipquXgQ%2FnW3x7XFeYpg%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blob/fba763f82528d2825831a26b4ae4e090c602208f/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp#L826"><span style="color:#0563C1">https://github.com/openjdk/jdk/blob/fba763f82528d2825831a26b4ae4e090c602208f/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp#L826</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"><a href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fopenjdk%2Fjdk%2Fblame%2Fmaster%2Fsrc%2Fhotspot%2Fshare%2Fgc%2Fshenandoah%2FshenandoahPacer.cpp%23L225&data=05%7C01%7Cadubrouski%40linkedin.com%7Cbf74d9dbec17428024d908daccacf25c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638047340421678150%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=93OjuodWHs6xDy9xg9Fd0CvdLVH07qr2G72Vz1UhZYM%3D&reserved=0" target="_blank" title="https://github.com/openjdk/jdk/blame/master/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp#L225"><span style="color:#0563C1">https://github.com/openjdk/jdk/blame/master/src/hotspot/share/gc/shenandoah/shenandoahPacer.cpp#L225</span></a></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">so I assume if there is no budget available it will pace a thread for up to 10ms, but it does not imply allocation failure.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">Heap class tries to allocate under lock and if unsuccessful considers this as allocation failure and handles it by calling ShenandoahControlThread. Does it mean that Pacer can’t cause GC to switch to degenerated mode or I am missing
 something?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">- If Pacer doesn't have budget to allocate memory it paces thread, but is there any global budget for pacing time or it is only per thread max (ShenandoahPacingMaxDelay)?<span class="m4157850829767933887apple-converted-space"> </span></span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">- It would really nice if you can sched some light on these transitions: Concurrent Mode -> Pacing (single thread and total pacing time for all threads) -> most importantly logic of transitioning from pacing to degenerated GC</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">I am trying to build a model which can tell me whether GC is healthy (fully concurrent), a bit unhealthy (pacing), unhealthy (degenerated or full GC) and how close are to the edge of the next state (a bit unhealthy -> unhealthy)</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">No rush and thanks a lot in advance.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">Regards,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;font-variant-caps:normal;text-align:start;word-spacing:0px">
<span style="color:black">Alex Dubrouski</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</body>
</html>