问题描述
JDK中的Java Mission Control工具提供有关新TLAB中的对象分配和TLAB外部分配的统计信息。 (它在内存/分配下)。这些统计数据的意义是什么,对于应用程序的性能有什么好处?我应该担心一些对象是否被分配到TLAB之外,如果是的话,我该怎么处理它? 解析方案
JDK中的Java Mission Control工具提供有关新TLAB中的对象分配和TLAB外部分配的统计信息。 (它在内存/分配下)。这些统计数据的意义是什么,对于应用程序的性能有什么好处?我应该担心一些对象是否被分配到TLAB之外,如果是的话,我该怎么处理它? 解析方案
因此,理想的场景是尽可能多的分配在TLAB中完成。
一些对象将被分配在TLAB之外,例如大对象。这是没有什么可担心的,只要TLAB之外的分配百分比与新TLAB中的分配百分比较低即可。
TLAB在每个线程的执行过程中都会动态调整大小。所以,如果一个线程分配非常多,它从堆中获得的新TLAB将会增加。如果你想要,你可以设置标志 -XX:MinTLABSize
来设置最小TLAB大小,例如
-XX:MinTLABSize = 4k
我的同事David Lindholm提供的答案:
The Java Mission Control tool in the JDK provides statistics about object allocation in new TLAB and allocations outside TLAB. (It's under Memory/Allocations). What is the significance of these statistics, what is good for the performance of an application? Should I be worried if some objects are allocated outside TLAB and if yes, what can I do about it?
A TLAB is a Thread Local Allocation Buffer. The normal way objects are allocated in HotSpot is within a TLAB. TLAB allocations can be done without synchronization with other threads, since the Allocation Buffer is Thread Local, synchronization is only needed when a new TLAB is fetched.
So, the ideal scenario is that as much as possible of the allocations are done in TLABs.
Some objects will be allocated outside TLABs, for example large objects. This is nothing to worry about as long as the percentage of allocations outside TLABs vs allocations in new TLABs is low.
The TLABs are dynamically resized during the execution for each thread individually. So, if a thread allocates very much, the new TLABs that it gets from the heap will increase in size. If you want you can try to set the flag -XX:MinTLABSize
to set minimum TLAB size, for example -XX:MinTLABSize=4k
Answer provided by my colleague David Lindholm :)
这篇关于新TLAB中的分配与TLAB之外的分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!