Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does the OpenJDK JVM parallelize bytecode?

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?

like image 605
user11171 Avatar asked Oct 03 '13 16:10

user11171


1 Answers

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.

like image 153
stonemetal Avatar answered Oct 02 '22 16:10

stonemetal