<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi Paul,<br>
    <br>
    The CSR proposes this method in java.lang.management.ThreadMXBean as
    a Java SE feature.<br>
    <br>
    Has this been discussed with the GC team to commit measuring current
    thread's allocated bytes as Java SE feature?   Can this be supported
    by all JVM implementation?   What is the overhead if this is enabled
    by default?  Does it need to be disabled?   This metric is from TLAB
    that might be okay.  This needs advice/discussion with GC experts.<br>
    <br>
    I see that CSR mentions it can be disabled and link to
    isThreadAllocatedMemoryEnabled() and
    setThreadAllocatedMemoryEnabled() methods but these methods are
    defined in com.sun.management.ThreadMXBean.   <br>
    <br>
    As Alan points out, current thread makes sense only in local VM
    management.  When this is monitored from a JMX client (e.g. jconsole
    to connect to a running JVM, "currentThreadAllowcatedBytes"
    attribute is the current thread in jconsole process which invoking
    Thread::currentThread?<br>
    <br>
    Mandy<br>
    <br>
    <div class="moz-cite-prefix">On 8/28/19 12:22 PM, Hohensee, Paul
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:CDB47B55-1327-4EFA-93E0-61E04A9EB61F@amazon.com">
      <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;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
      <div class="WordSection1">
        <p class="MsoNormal"><span style="color:black">Please review a
            performance improvement for
            ThreadMXBean.getThreadAllocatedBytes and the addition of
            getCurrentThreadAllocatedBytes.<o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black"> <o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black">JBS issue:<span
              class="apple-converted-space"> </span><a
              href="https://bugs.openjdk.java.net/browse/JDK-8207266"
              title="https://bugs.openjdk.java.net/browse/JDK-8207266"
              moz-do-not-send="true"><span style="color:#954F72">https://bugs.openjdk.java.net/browse/JDK-8207266</span></a><o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black">Webrev:<span
              class="apple-converted-space"> </span><a
              href="http://cr.openjdk.java.net/~phh/8207266/webrev.00/"
              title="http://cr.openjdk.java.net/~phh/8207266/webrev.00/"
              moz-do-not-send="true"><span style="color:#954F72">http://cr.openjdk.java.net/~phh/8207266/webrev.00/</span></a><o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black">CSR:<span
              class="apple-converted-space"> </span><a
              href="https://bugs.openjdk.java.net/browse/JDK-8230311"
              title="https://bugs.openjdk.java.net/browse/JDK-8230311"
              moz-do-not-send="true"><span style="color:#954F72">https://bugs.openjdk.java.net/browse/JDK-8230311</span></a><o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black"> <o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black">Previous email threads:<br>
            <a
href="https://mail.openjdk.java.net/pipermail/serviceability-dev/2018-July/024441.html"
              moz-do-not-send="true"><span style="color:#954F72">https://mail.openjdk.java.net/pipermail/serviceability-dev/2018-July/024441.html</span></a><span
              class="apple-converted-space"> </span><br>
            <a
href="https://mail.openjdk.java.net/pipermail/serviceability-dev/2018-August/024763.html"
title="https://mail.openjdk.java.net/pipermail/serviceability-dev/2018-August/024763.html"
              moz-do-not-send="true"><span style="color:#954F72">https://mail.openjdk.java.net/pipermail/serviceability-dev/2018-August/024763.html</span></a><o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black"> <o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black">The CSR is for adding
            ThreadMXBean.getCurrentThreadAllocatedBytes. I’d be great
            for someone to review it.<o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black"> <o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black">I took Mandy’s advice and put the
            fast paths in the library code. I added a new JMM method
            GetOneThreadsAllocatedBytes that works the same as
            GetThreadCpuTime: it uses a thread_id value of zero to
            distinguish the current thread. On my Mac laptop, the result
            runs 47x faster for the current thread than the old
            implementation.<o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black"> <o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black">The 3 tests in<span
              class="apple-converted-space"> </span>test/jdk/com/sun/management/ThreadMXBean
            all pass. I added code to ThreadAllocatedMemory.java to test
            getCurrentThreadAllocatedBytes as well as variations on
            getThreadAllocatedBytes(id). A submit repo job is in
            progress.<o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black"> <o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black">Thanks,<o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black"> <o:p></o:p></span></p>
        <p class="MsoNormal" style="caret-color: rgb(0, 0,
          0);font-variant-caps: normal;orphans:
          auto;text-align:start;widows: auto;-webkit-text-size-adjust:
          auto;-webkit-text-stroke-width: 0px;word-spacing:0px">
          <span style="color:black">Paul<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p> </o:p></span></p>
      </div>
    </blockquote>
    <br>
  </body>
</html>