In some applications with a lot of threads we sometimes notice high system time during GC; investigation showed that at least one cause for this can be PLAB allocation.
If many threads try to refill their PLAB at approximately the same time, the heap lock will be taken, causing lots of contention.
The attached file shows high pause time spikes caused by that on a micro benchmark.
Find ways to fix this.
Following are the test cases for the given figure:
[0] -XX:-ResizePLAB
[1] -XX:+ResizePLAB
[2] -XX:-ResizePLAB -XX:OldPLABSize=2097152 -XX:YoungPLABSize=2097152
[3] -XX:-ResizePLAB -XX:OldPLABSize=0 -XX:YoungPLABSize=0
For this test, [2] has the best results. However, we can not give too big PLAB size, due to too much wasted space.