[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-serviceability-dev
Subject:    Re: RFR (M): 8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
From:       Mandy Chung <mandy.chung () oracle ! com>
Date:       2019-08-30 23:25:30
Message-ID: 0d42d653-d158-a6e4-45b6-84f087c7e592 () oracle ! com
[Download RAW message or body]

CSR reviewed.

management.cpp
2083         java_thread = (JavaThread*)THREAD;
2084         if (java_thread->is_Java_thread()) {
2085             return java_thread->cooked_allocated_bytes();
2086         }

The cast should be done after is_Java_thread() test.

ThreadImpl.java
   162         private void throwIfNullThreadIds(long[] ids) {

Even better: simply use Objects::requiresNonNull and this method can be 
removed.

This suggests positive naming alternative to 
throwIfThreadAllocatedMemoryNotSupported - 
"ensureThreadAllocatedMemorySupported" (sorry I should have suggested that)

ThreadMXBean.java
   130           * @throws java.lang.UnsupportedOperationException if the Java 
virtual

Nit: "java.lang." can be dropped.

@since 14 is missing.

Mandy

On 8/30/19 3:33 PM, Hohensee, Paul wrote:
>
> Thanks for your review, Mandy. Revised webrev at 
> http://cr.openjdk.java.net/~phh/8207266/webrev.02/.
>
> I updated the CSR with your suggested javadoc for 
> getCurrentThreadAllocatedBytes. It now matches that for 
> getCurrentThreadUserTime and getCurrentThreadCputime. I also fixed the 
> "convenient" -> "convenience" typos in j.l.m.ThreadMXBean.java.
>
> I meant GetOneThreads to be the possessive, but don't feel strongly 
> either way so I'm fine with GetOneThread.
>
> I updated ThreadImpl.java as you suggested, though in 
> getThreadAllocatedBytes(long[] ids) I had to add a 
> redundant-in-the-not-length-1-case check for a null ids reference.
> Would someone take a look at the Hotspot side and the test please?
> Paul
>
> *From: *Mandy Chung <mandy.chung@oracle.com>
> *Date: *Friday, August 30, 2019 at 10:22 AM
> *To: *"Hohensee, Paul" <hohensee@amazon.com>
> *Cc: *OpenJDK Serviceability <serviceability-dev@openjdk.java.net>, 
> "hotspot-gc-dev@openjdk.java.net" <hotspot-gc-dev@openjdk.java.net>
> *Subject: *Re: RFR (M): 8207266: 
> ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
>
> OK.   That's better.   Some review comments:
>
> The javadoc of getCurrentThreadAllocatedBytes() can simply say:
>
> "Returns an approximation of the total amount of memory, in bytes,
> allocated in heap memory for the current thread.
>
> This is a convenient method for local management use and is equivalent
> to calling getThreadAllocatedBytes(Thread.currentThread().getId()).
>
>
> src/hotspot/share/include/jmm.h
>
> GetOneThreadsAllocatedMemory: s/OneThreads/OneThread/
>
> sun/management/ThreadImpl.java
>
>    43         private static final String 
> THREAD_ALLOCATED_MEMORY_NOT_SUPPORTED =
>    44                 "Thread allocated memory measurement is not supported.";
>
> if (!isThreadAllocatedMemorySupported()) {
>      throw new 
> UnsupportedOperationException(THREAD_ALLOCATED_MEMORY_NOT_SUPPORTED);
> }
>
> Perhaps the above can be refactored as 
> throwIfAllocatedMemoryUnsupported() method.
>
>   391                 if (ids.length == 1) {
>   392                         sizes[0] = -1;
>   :
>   398                         if (ids.length == 1) {
>   399                                 long id = ids[0];
>   400                                 sizes[0] = getThreadAllocatedMemory0(
>   401                                         Thread.currentThread().getId() == id ? 0 : id);
>   402                         } else {
>
> It seems cleaner to handle the 1-element array case at the beginning
> of this method:
>      if (ids.length == 1) {
>              long size = getThreadAllocatedBytes(ids[0]);
>              return new long[] { size };
>      }
>
> I didn't review the hotspot implementation and the test.
>
> Mandy
>
> On 8/29/19 10:01 AM, Hohensee, Paul wrote:
>
>     My bad, Mandy. The webrev puts getCurrentThreadAllocatedBytes in
>     com.sun.management.ThreadMXBean along with the current two
>     getThreadAllocatedBytes methods for the reasons you list. I've
>     updated the CSR to specify com.sun.management and added a
>     rationale. AllocatedBytes is currently enabled by Hotspot by
>     default because the overhead of recording TLAB occupancy is
>     negligible.
>
>     There's no new GC code, nor will there be, so imo we don't have to
>     involve the GC folks. I.e., the new JMM method
>     GetOneThreadsAllocatedBytes uses the existing
>     cooked_allocated_bytes JavaThread method, and
>     getCurrentThreadAllocatedBytes is the same as
>     getThreadAllocatedBytes: it just bypasses the thread lookup code.
>
>     I hadn't tracked down what happens when getCurrentThreadUserTime
>     and getCurrentThreadCpuTime are called before, but if I'm not
>     mistaken, it the code in jcmd() in attachListener.cpp will call
>     GetThreadCpuTimeWithKind in management.cpp, and it will ultimately
>     use Thread::current() as the subject of the call, see
>     os::current_thread_cpu_time in os_linux.cpp. That means that the
>     CurrentThread methods should work remotely the same way they do
>     locally. GetOneThreadsAllocatedBytes in management.cpp uses THREAD
>     as its subject when called on behalf of
>     getCurrentThreadAllocatedBytes, so it will also uses the current
>     remote Java thread. Even if these methods only worked locally,
>     there are many setups where apps are self-monitoring that could
>     use the performance improvement.
>
>     Thanks,
>
>     Paul
>
>     *From: *Mandy Chung <mandy.chung@oracle.com>
>     <mailto:mandy.chung@oracle.com>
>     *Date: *Wednesday, August 28, 2019 at 3:59 PM
>     *To: *"Hohensee, Paul" <hohensee@amazon.com>
>     <mailto:hohensee@amazon.com>
>     *Cc: *OpenJDK Serviceability <serviceability-dev@openjdk.java.net>
>     <mailto:serviceability-dev@openjdk.java.net>,
>     "hotspot-gc-dev@openjdk.java.net"
>     <mailto:hotspot-gc-dev@openjdk.java.net>
>     <hotspot-gc-dev@openjdk.java.net>
>     <mailto:hotspot-gc-dev@openjdk.java.net>
>     *Subject: *Re: RFR (M): 8207266:
>     ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread
>
>     Hi Paul,
>
>     The CSR proposes this method in java.lang.management.ThreadMXBean
>     as a Java SE feature.
>
>     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.
>
>     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.
>
>     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?
>
>     Mandy
>
>     On 8/28/19 12:22 PM, Hohensee, Paul wrote:
>
>         Please review a performance improvement for
>         ThreadMXBean.getThreadAllocatedBytes and the addition of
>         getCurrentThreadAllocatedBytes.
>
>         JBS issue:https://bugs.openjdk.java.net/browse/JDK-8207266
>
>         Webrev:http://cr.openjdk.java.net/~phh/8207266/webrev.00/
>
>         CSR:https://bugs.openjdk.java.net/browse/JDK-8230311
>
>         Previous email threads:
>         https://mail.openjdk.java.net/pipermail/serviceability-dev/2018-July/024441.html
>         https://mail.openjdk.java.net/pipermail/serviceability-dev/2018-August/024763.html
>
>         The CSR is for adding
>         ThreadMXBean.getCurrentThreadAllocatedBytes. I'd be great for
>         someone to review it.
>
>         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.
>
>         The 3 tests intest/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.
>
>         Thanks,
>
>         Paul
>
>
>
>
>
>


[Attachment #3 (text/html)]

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    CSR reviewed.<br>
    <br>
    management.cpp<br>
    2083         java_thread = (JavaThread*)THREAD;<br>
    2084         if (java_thread-&gt;is_Java_thread()) {<br>
    2085             return java_thread-&gt;cooked_allocated_bytes();<br>
    2086         }<br>
    <br>
    The cast should be done after is_Java_thread() test.<br>
    <br>
    ThreadImpl.java<br>
      162         private void throwIfNullThreadIds(long[] ids) {<br>
    <br>
    Even better: simply use Objects::requiresNonNull and this method can
    be removed.<br>
    <br>
    This suggests positive naming alternative to
    throwIfThreadAllocatedMemoryNotSupported -
    "ensureThreadAllocatedMemorySupported" (sorry I should have
    suggested that)<br>
    <br>
    ThreadMXBean.java<br>
      130           * @throws java.lang.UnsupportedOperationException if the
    Java virtual<br>
    <br>
    Nit: "java.lang." can be dropped.<br>
    <br>
    @since 14 is missing.<br>
    <br>
    Mandy<br>
    <br>
    <div class="moz-cite-prefix">On 8/30/19 3:33 PM, Hohensee, Paul
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:30EA5D0C-1AEC-4242-B17B-CA4D39ECAF71@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;}
pre
	{mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:10.0pt;
	font-family:"Courier New";}
tt
	{mso-style-priority:99;
	font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
	{mso-style-name:msonormal;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
span.EmailStyle19
	{mso-style-type:personal;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
span.apple-converted-space
	{mso-style-name:apple-converted-space;}
span.EmailStyle21
	{mso-style-type:personal;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
span.EmailStyle22
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted";
	font-family:"Courier New";}
.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>
      <div class="WordSection1">
        <p class="MsoNormal"><span style="font-size:11.0pt">Thanks for
            your review, Mandy. Revised webrev at
            <a class="moz-txt-link-freetext" \
href="http://cr.openjdk.java.net/~phh/8207266/webrev.02/">http://cr.openjdk.java.net/~phh/8207266/webrev.02/</a>.<o:p></o:p></span></p>
                
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p>  </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">I updated
            the CSR with your suggested javadoc for
            getCurrentThreadAllocatedBytes. It now matches that for
            getCurrentThreadUserTime and getCurrentThreadCputime. I also
            fixed the "convenient" -&gt; "convenience" typos in
            j.l.m.ThreadMXBean.java.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p>  </o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt">I meant
            GetOneThreads to be the possessive, but don't feel strongly
            either way so I'm fine with GetOneThread.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p>  </o:p></span></p>
        <pre><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">I \
updated ThreadImpl.java as you suggested, though </span><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">in \
getThreadAllocatedBytes(long[] ids) I had to add a redundant-in-the-not-length-1-case \
                check for a null ids reference.<o:p></o:p></span></pre>
        <pre><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p> \
</o:p></span></pre>  <pre><span \
style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Would someone \
                take a look at the Hotspot side and the test \
                please?<o:p></o:p></span></pre>
        <pre><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif"><o:p> \
                </o:p></span></pre>
        <pre><span style="font-size:11.0pt;font-family:&quot;Calibri&quot;,sans-serif">Paul<o:p></o:p></span></pre>
                
        <p class="MsoNormal"><span style="font-size:11.0pt"><o:p>  </o:p></span></p>
        <div style="border:none;border-top:solid #B5C4DF
          1.0pt;padding:3.0pt 0in 0in 0in">
          <p class="MsoNormal"><b><span style="color:black">From: </span></b><span
              style="color:black">Mandy Chung
              <a class="moz-txt-link-rfc2396E" \
href="mailto:mandy.chung@oracle.com">&lt;mandy.chung@oracle.com&gt;</a><br>  <b>Date: \
                </b>Friday, August 30, 2019 at 10:22 AM<br>
              <b>To: </b>"Hohensee, Paul" <a class="moz-txt-link-rfc2396E" \
href="mailto:hohensee@amazon.com">&lt;hohensee@amazon.com&gt;</a><br>  <b>Cc: \
                </b>OpenJDK Serviceability
              <a class="moz-txt-link-rfc2396E" \
href="mailto:serviceability-dev@openjdk.java.net">&lt;serviceability-dev@openjdk.java.net&gt;</a>,
                
              <a class="moz-txt-link-rfc2396E" \
                href="mailto:hotspot-gc-dev@openjdk.java.net">"hotspot-gc-dev@openjdk.java.net"</a>
                
              <a class="moz-txt-link-rfc2396E" \
href="mailto:hotspot-gc-dev@openjdk.java.net">&lt;hotspot-gc-dev@openjdk.java.net&gt;</a><br>
  <b>Subject: </b>Re: RFR (M): 8207266:
              ThreadMXBean::getThreadAllocatedBytes() can be quicker for
              self thread<o:p></o:p></span></p>
        </div>
        <div>
          <p class="MsoNormal"><span style="font-size:11.0pt"><o:p>  \
</o:p></span></p>  </div>
        <p class="MsoNormal" style="margin-bottom:12.0pt"><tt><span
              style="font-size:10.0pt">OK.   That's better.   Some review
              comments:</span></tt><span
            style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><br>
            <br>
            <tt>The javadoc of getCurrentThreadAllocatedBytes() can
              simply say:</tt><br>
            <br>
            <tt>"Returns an approximation of the total amount of memory,
              in bytes,</tt><br>
            <tt>allocated in heap memory for the current thread.</tt><br>
            <br>
            <tt>This is a convenient method for local management use and
              is equivalent</tt><br>
            <tt>to calling
              getThreadAllocatedBytes(Thread.currentThread().getId()).  
            </tt><br>
            <br>
            <br>
          </span>src/hotspot/share/include/jmm.h<br>
          <br>
          <tt><span style="font-size:10.0pt">GetOneThreadsAllocatedMemory:
              s/OneThreads/OneThread/</span></tt><span
            style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><br>
            <br>
            <tt>sun/management/ThreadImpl.java</tt><br>
            <br>
            <tt>   43         private static final String
              THREAD_ALLOCATED_MEMORY_NOT_SUPPORTED =</tt><br>
            <tt>   44                 "Thread allocated memory measurement is not
              supported.";</tt><br>
            <br>
            <tt>if (!isThreadAllocatedMemorySupported()) {</tt><br>
            <tt>     throw new
              UnsupportedOperationException(THREAD_ALLOCATED_MEMORY_NOT_SUPPORTED);</tt><br>
  <tt>}</tt><br>
            <br>
            <tt>Perhaps the above can be refactored as
              throwIfAllocatedMemoryUnsupported() method.</tt><br>
            <tt>  </tt><br>
            <tt>  391                 if (ids.length == 1) {</tt><br>
            <tt>  392                         sizes[0] = -1;</tt><br>
            <tt>  :</tt><br>
            <tt>  398                         if (ids.length == 1) {</tt><br>
            <tt>  399                                 long id = ids[0];</tt><br>
            <tt>  400                                 sizes[0] =
              getThreadAllocatedMemory0(</tt><br>
            <tt>  401                                         \
Thread.currentThread().getId()  == id ? 0 : id);</tt><br>
            <tt>  402                         } else {</tt><br>
            <br>
            <tt>It seems cleaner to handle the 1-element array case at
              the beginning</tt><br>
            <tt>of this method:</tt><br>
            <tt>     if (ids.length == 1) {</tt><br>
            <tt>             long size = getThreadAllocatedBytes(ids[0]);</tt><br>
            <tt>             return new long[] { size };</tt><br>
            <tt>     }</tt><br>
            <br>
            <tt>I didn't review the hotspot implementation and the test.</tt><br>
            <tt>     </tt><br>
            <tt>Mandy</tt></span><o:p></o:p></p>
        <div>
          <p class="MsoNormal">On 8/29/19 10:01 AM, Hohensee, Paul
            wrote:<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal"><span style="font-size:11.0pt">My bad,
              Mandy. The webrev puts getCurrentThreadAllocatedBytes in
              com.sun.management.ThreadMXBean along with the current two
              getThreadAllocatedBytes methods for the reasons you list.
              I've updated the CSR to specify com.sun.management and
              added a rationale. AllocatedBytes is currently enabled by
              Hotspot by default because the overhead of recording TLAB
              occupancy is negligible.</span><o:p></o:p></p>
          <p class="MsoNormal"><span style="font-size:11.0pt">  \
</span><o:p></o:p></p>  <p class="MsoNormal"><span style="font-size:11.0pt">There's \
no  new GC code, nor will there be, so imo we don't have to
              involve the GC folks. I.e., the new JMM method
              GetOneThreadsAllocatedBytes uses the existing
              cooked_allocated_bytes JavaThread method, and
              getCurrentThreadAllocatedBytes is the same as
              getThreadAllocatedBytes: it just bypasses the thread
              lookup code.</span><o:p></o:p></p>
          <p class="MsoNormal"><span style="font-size:11.0pt">  \
</span><o:p></o:p></p>  <p class="MsoNormal"><span style="font-size:11.0pt">I hadn't
              tracked down what happens when getCurrentThreadUserTime
              and getCurrentThreadCpuTime are called before, but if I'm
              not mistaken, it the code in jcmd() in attachListener.cpp
              will call GetThreadCpuTimeWithKind in management.cpp, and
              it will ultimately use Thread::current() as the subject of
              the call, see os::current_thread_cpu_time in os_linux.cpp.
              That means that the CurrentThread methods should work
              remotely the same way they do locally.
              GetOneThreadsAllocatedBytes in management.cpp uses THREAD
              as its subject when called on behalf of
              getCurrentThreadAllocatedBytes, so it will also uses the
              current remote Java thread. Even if these methods only
              worked locally, there are many setups where apps are
              self-monitoring that could use the performance
              improvement.</span><o:p></o:p></p>
          <p class="MsoNormal"><span style="font-size:11.0pt">  \
                </span><o:p></o:p></p>
          <p class="MsoNormal"><span \
                style="font-size:11.0pt">Thanks,</span><o:p></o:p></p>
          <p class="MsoNormal"><span style="font-size:11.0pt">  \
                </span><o:p></o:p></p>
          <p class="MsoNormal"><span \
                style="font-size:11.0pt">Paul</span><o:p></o:p></p>
          <p class="MsoNormal"><span style="font-size:11.0pt">  \
</span><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="color:black">From: </span></b><span
                style="color:black">Mandy Chung
                <a href="mailto:mandy.chung@oracle.com"
                  moz-do-not-send="true">&lt;mandy.chung@oracle.com&gt;</a><br>
                <b>Date: </b>Wednesday, August 28, 2019 at 3:59 PM<br>
                <b>To: </b>"Hohensee, Paul" <a
                  href="mailto:hohensee@amazon.com"
                  moz-do-not-send="true">&lt;hohensee@amazon.com&gt;</a><br>
                <b>Cc: </b>OpenJDK Serviceability <a
                  href="mailto:serviceability-dev@openjdk.java.net"
                  moz-do-not-send="true">
                  &lt;serviceability-dev@openjdk.java.net&gt;</a>, <a
                  href="mailto:hotspot-gc-dev@openjdk.java.net"
                  moz-do-not-send="true">
                  "hotspot-gc-dev@openjdk.java.net"</a> <a
                  href="mailto:hotspot-gc-dev@openjdk.java.net"
                  moz-do-not-send="true">
                  &lt;hotspot-gc-dev@openjdk.java.net&gt;</a><br>
                <b>Subject: </b>Re: RFR (M): 8207266:
                ThreadMXBean::getThreadAllocatedBytes() can be quicker
                for self thread</span><o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal"><span style="font-size:11.0pt">  \
</span><o:p></o:p></p>  </div>
          <p class="MsoNormal" style="margin-bottom:12.0pt">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<o:p></o:p></p>
          <div>
            <p class="MsoNormal">On 8/28/19 12:22 PM, Hohensee, Paul
              wrote:<o:p></o:p></p>
          </div>
          <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
            <p class="MsoNormal"><span style="color:black">Please review
                a performance improvement for
                ThreadMXBean.getThreadAllocatedBytes and the addition of
                getCurrentThreadAllocatedBytes.</span><o:p></o:p></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">  </span><o:p></o:p></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></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></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></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></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></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></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">  </span><o:p></o:p></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>
              </span><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 style="color:black">  \
</span></span><span  style="color:black"><br>
              </span><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></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">  </span><o:p></o:p></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.</span><o:p></o:p></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">  </span><o:p></o:p></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.</span><o:p></o:p></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">  </span><o:p></o:p></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.</span><o:p></o:p></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">  </span><o:p></o:p></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,</span><o:p></o:p></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">  </span><o:p></o:p></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</span><o:p></o:p></p>
            <p class="MsoNormal"><span style="font-size:11.0pt">  \
</span><o:p></o:p></p>  </blockquote>
          <p class="MsoNormal"><span style="font-size:11.0pt"><br>
              <br>
              <br>
            </span><o:p></o:p></p>
        </blockquote>
        <p class="MsoNormal"><span style="font-size:11.0pt"><br>
            <br>
            <o:p></o:p></span></p>
      </div>
    </blockquote>
    <br>
  </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic