Does -XX: parallelGCThreads = 8 relates to the number of Cores in relation to Amdahl's law?

SteewDK picture SteewDK · Feb 17, 2014 · Viewed 23.2k times · Source

Intro:

I am currently working on a piece of software where I benchmark a sequential program with a multithreaded one. My hardware has 24 cores available and 16GB of RAM. My program is written in Java but executed from MATLAB due to the need for plotting. Upon opening of MATLAB the following message is displayed:

Picked up JAVA_TOOL:OPTIONS: -XX:parallelGCThreads = 8 - Xmx8g -Dsun.java2d.pmoffscreen = false

Theory

Now in accordance with Amdahl's Law the maksimum performance increase would be defined as 1/(B-(1-B)/P), where B is the sequential fraction and P is the number of processors. In my case I have that B = 0.01, (1-B = .99) and P = 24 This gives me a theoretical maximum performance increase of around 20.

Now, as I understand parallelGCThreads it is the maximum number of Garbage Collector threads available. After doing some intensive testing on my program it appears that the maximum ratio increase I have been able to achieve was a factor of 7.5 which is no where near the theoretical of 20. However, If I substitute P = 8 I get a theoretical limit of 7.8 which is very close to the one obtained in my program.

Question

Does parallelGCThreads actually limit the amount of threads such that Amdahl's law should be used with P = 8 and not P = 24?

Thanks in advance!

Answer

Stephen C picture Stephen C · Feb 17, 2014

Does parallelGCThreads actually limit the amount of threads such that Amdahl's law should be used with P = 8 and not P = 24?

No. The number of GC threads does not directly affect the performance of your program while doing "real" work. (It might affect it if the program generated lots of garbage, but the analysis would be rather complicated ... and it certainly would not replace P in the Amdahl equation.)

You could try tweaking the parallelGCThreads parameter to see what effect it has, but there is probably something else (not GC) that is impacting your multi-threaded performance resulting in lower speed-up ratios than you anticipated. Most likely it is something to do with the application; e.g. memory bandwidth contention, or Java lock contention.

FWIW - it is unusual for a multi-threaded program to get close to the theoretical limit set by Amdahl's Law.