Java -XX:parallelGCThreads = 8 是否与阿姆达尔定律相关的内核数量有关?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21835101/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 10:59:07  来源:igfitidea点击:

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

javamultithreadingmatlabparallelism-amdahl

提问by SteewDK

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:

我目前正在开发一款软件,我用多线程程序对顺序程序进行基准测试。我的硬件有 24 个可用内核和 16GB 内存。我的程序是用 Java 编写的,但由于需要绘图而从 MATLAB 执行。打开 MATLAB 后,将显示以下消息:

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

Theory

理论

Now in accordance with Amdahl's Lawthe 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.

现在,根据阿姆达尔定律,最大性能提升将定义为 1/(B-(1-B)/P),其中 B 是顺序分数,P 是处理器数量。在我的情况下,我有 B = 0.01、(1-B = .99) 和 P = 24 这使我理论上的最大性能提高了大约 20。

Now, as I understand parallelGCThreadsit 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.

现在,据我所知,parallelGCThreads这是可用的最大垃圾收集器线程数。在对我的程序进行了一些密集测试之后,似乎我能够实现的最大比率增加是 7.5 倍,这与理论值 20 相差甚远。但是,如果我替换 P = 8,我会得到一个理论极限7.8 与我的程序中获得的非常接近。

Question

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

parallelGCThreads实际上是否限制了线程的数量,以便 Amdahl 定律应该与 P = 8 而不是 P = 24 一起使用?

Thanks in advance!

提前致谢!

采纳答案by Stephen C

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

parallelGCThreads 是否真的限制了线程的数量,以至于阿姆达尔定律应该与 P = 8 而不是 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 Pin the Amdahl equation.)

不会。GC 线程的数量在执行“实际”工作时不会直接影响程序的性能。(如果程序产生大量垃圾可能会影响它,但分析会相当复杂......它肯定不会P在Amdahl方程中替换。)

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.

您可以尝试调整 parallelGCThreads 参数以查看它有什么影响,但可能还有其他因素(不是 GC)会影响您的多线程性能,从而导致比您预期的更低的加速比。很可能与应用程序有关;例如内存带宽争用,或Java 锁争用。

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

FWIW - 多线程程序接近阿姆达尔定律设定的理论极限是不寻常的。