I've implemented an algorithm using single-threaded Java code. When I run my program using JIT compilation enabled it saturates all 8 cores on my machine. When I run the same program using the -Xint
JVM option to disable JIT compilation it runs on a single core as expected.
This is my Java version info:
java version "1.7.0_25"
OpenJDK Runtime Environment (IcedTea 2.3.10) (7u25-2.3.10-1ubuntu0.12.10.2)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)
Why does it seem like my code gets parallelized and where can I find more information on when HotSpot can parallelize code?
Java doesn't auto parallelize code, my guess is that the core saturation you are seeing is the JIT compiling your code. Make your test program input larger so it runs longer(maybe a 2-3 min.) and see if it tails off after a while.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With