Java 7 fork / join framework does not use all available processor power

I am using the Java fork-join framework to handle calculations using CPU.

I slightly changed the "sequential threshold" (used to determine whether to create subtasks or do the work), but to my disappointment, switching from single-threaded to 4 + 4 cores only doubles overall performance. The pool reports about 8 processors, and when I manually install 2,3,4, I see a gradual increase in performance, but still it reaches almost twice the throughput of one thread. In addition, monitoring Linux system activity is about 50% for this Java process.

Also very suspicious is the fact that when running several Java processes, the collective bandwidth is closer (almost 4 times faster than a single thread), and the System Activity monitor shows a higher level of CPU usage.

Is it possible that there is a restriction in Java, Linux, or a fork / join framework that would prohibit full CPU usage? Any suggestions or similar events?

NB. This is an Intel 3770 processor with four cores and four hyper-threaded cores, working with Oracle Java 7r13 in a Linux Mint box.

+4
source share
1 answer

Thanks for the thoughts and answers, that's it! From your suggestions, I came to the conclusion that the problem is not in the structure itself and some testing continued, and it turned out that after a few minutes the processor load dropped to 15%!

Turns off, Random (which I use widely) has poor performance in multi-threaded tuning. The solution was to use ThreadLocalRandom.current () instead of nextXXX (). Now I use 80% usage (there are several consecutive passes left). Cool!

Thanks again for putting me on the right track.

+1
source

Source: https://habr.com/ru/post/1469284/


All Articles