RFR (M): 8207266: ThreadMXBean::getThreadAllocatedBytes() can be quicker for self thread

Hohensee, Paul hohensee at amazon.com
Wed Aug 28 19:22:19 UTC 2019


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 in 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.

Thanks,

Paul

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20190828/70e18702/attachment.html>


More information about the serviceability-dev mailing list