<div dir="ltr"><div dir="ltr"><span id="gmail-docs-internal-guid-d475c433-7fff-061d-68ef-b7efa2689235"><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;vertical-align:baseline">Hi Volker,</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;vertical-align:baseline">Resurrecting this thread to continue this discussion, as I created a PR to add these counters upstream: </span><a href="https://github.com/openjdk/jdk/pull/15082" style="text-decoration-line:none"><span style="font-family:Arial,sans-serif;background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;text-decoration-line:underline;vertical-align:baseline">https://github.com/openjdk/jdk/pull/15082</span></a><span style="font-family:Arial,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;vertical-align:baseline"> </span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;vertical-align:baseline">I think the main benefit we see from adding these counters is that it is readily consumable and easy to parse, compared to the alternatives you suggested. I left some further thoughts from Man and myself as a comment here: </span><a href="https://bugs.openjdk.org/browse/JDK-8315149" style="text-decoration-line:none"><span style="font-family:Arial,sans-serif;background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;text-decoration-line:underline;vertical-align:baseline">https://bugs.openjdk.org/browse/JDK-8315149</span></a><span style="font-family:Arial,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;vertical-align:baseline"> </span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;vertical-align:baseline">Please let me know your thoughts!</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;vertical-align:baseline">Best,</span></p><br><p dir="ltr" style="line-height:1.38;margin-top:0pt;margin-bottom:0pt"><span style="font-family:Arial,sans-serif;color:rgb(0,0,0);background-color:transparent;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;vertical-align:baseline">~ Jonathan</span></p></span><br class="gmail-Apple-interchange-newline"></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 31, 2022 at 9:55 AM Volker Simonis <<a href="mailto:volker.simonis@gmail.com" target="_blank">volker.simonis@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Oct 19, 2022 at 7:15 PM Man Cao <<a href="mailto:manc@google.com" target="_blank">manc@google.com</a>> wrote:<br>
><br>
> Hi Volker,<br>
><br>
> Yes, we are aware of "sun.gc.collector.{0,1,2}.time", and they only account for pause time.<br>
> Accounting for only pause time does not accurately measure GC overhead for collectors with a large portion of concurrent work.<br>
> This is also the reason why heuristics based on -XX:GCTimeRatio are broken for G1. <a href="https://mail.openjdk.org/pipermail/hotspot-gc-dev/2021-May/035241.html" rel="noreferrer" target="_blank">https://mail.openjdk.org/pipermail/hotspot-gc-dev/2021-May/035241.html</a> has a related discussion.<br>
><br>
> Yes, the CPU time metric sums up CPU time from all parallel GC worker threads and concurrent GC threads.<br>
> I just found <a href="https://bugs.openjdk.org/browse/JDK-8291753" rel="noreferrer" target="_blank">https://bugs.openjdk.org/browse/JDK-8291753</a> which exports CPU time via JFR events. However, it seems to only account for CPU time spent during pauses, which does not cover all concurrent work. I'll do more digging and follow up when I create an RFE.<br>
><br>
<br>
I think you're right. But we also have the<br>
sun.management.HotspotInternal MBean which already exports the CPU<br>
time for all non-Java threads through the InternalThreadCpuTimes<br>
attribute of the sun.management:type=HotspotThreading MBean.<br>
Alternatively, we can also get the CPU time of all GC threads from<br>
/proc/<pid>/task<thread-id>/stat (by summing up the times from all<br>
threads which contain GC/G1 in their name (i.e.<br>
/proc/<pid>/task/<tid>/comm)). This is also what<br>
InternalThreadCpuTimes is using to get the the CPU times of non-Java<br>
threads if pthread_getcpuclockid() is not available.<br>
<br>
So the question is if it is necessarily to export the CPU time of GC<br>
threads through hsperf at all, if we can already get this information<br>
from the /proc file system?<br>
<br>
> -Man<br>
</blockquote></div>
</div>