Option -gc true considered harmful

Jens Wilke jw_list at headissue.com
Tue May 2 04:21:20 UTC 2017


Hi All,

for quite a while I used the option -gc true in the thinking that the results 
should be more stable. After my last experiments with deriving memory 
consumption metrics I did some tests without the option.

The result is that without the option -gc true the throughput gets slightly 
higher. This is contrary to the expectation. Since during the benchmark 
iteration a GC is triggered multiple times, doing a full GC outside the 
benchmark measurements should increase throughput.

My assumption is that the cause is in the current JMH code which forces the 
GC. It waits until the GC is finished by examination of a JMX counter value, 
however the CMS collector actually generates two GC events and two counter 
increments like this:

30.998: [GC (System.gc()) [PSYoungGen: 144096K->3840K(153088K)] ....
31.004: [Full GC (System.gc()) [PSYoungGen: 3840K->0K(153088K)]....

So probably the benchmark iteration starts while the full GC is in progress.
NB: G1 only generates one event for a forced garbage collection.

I didn't dig into this deeper, since I decided not to use the option any more. 
That's why the post is a little vague and the "hard evidence"  and numbers are 
missing.

Best,

Jens

-- 
"Everything superfluous is wrong!"

   // Jens Wilke - headissue GmbH - Germany
 \//  https://headissue.com


More information about the jmh-dev mailing list