-XX:+StressLCM, -XX:+StressGCM Options for JVM

≯℡__Kan透↙ 提交于 2021-02-04 17:14:05

问题


While playing with some jcstress code, I noticed two parameters that are very new to me: StressLCM and StressGCM.

The very first thing to do for me was searching for these in the source code itself and while I have found some things, it is still unclear what they actually do. I was really hoping to see some comments in the source code that would shed some light, but no luck.

I also found the bug description where these have been added, but the explanation made no sense for me:

Randomize instruction scheduling in LCM/GCM.

Can someone explain what they do, if possible in plain english?


回答1:


LCM / GCM stands for Local Code Motion / Global Code Motion. To optimize CPU utilization, compiler may reorder independent instructions without changing the semantics of the code. Compiler tries to find the most optimal (from performance perspective) order of instructions. This is called instruction scheduling, and that's what LCM / GCM do.

With -XX:+StressLCM / -XX:+StressGCM options the instruction scheduling works in a bit different way. It no longer tries to find the best schedule, but instead chooses a random instruction order within the allowed constraints, still keeping the original semantics unchanged. Such nondeterministic behavior helps to test more combinations of instruction interleaving, which is essential in finding subtle concurrency issues.



来源:https://stackoverflow.com/questions/56273136/xxstresslcm-xxstressgcm-options-for-jvm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!