Turbo charge CPU utilization in Fork/Join using the ManagedBlocker
What solutions can ManagedBlocker provide for the Fork/Join framework? How can you reduce wasted CPU cycles? Dr. Heinz Kabutz gives us answers to these questions and more.
Fork/Join is a framework for parallelizing calculations using recursive decomposition, also called divide and conquer. These algorithms occasionally end up duplicating work, especially at the beginning of the run. In this talk, Dr. Heinz Kabutz demonstrates this issue and offer a solution in the form of the ManagedBlocker. Combined with the Fork/Join, it can keep parallelism at the desired level.
What’s more, in this session, Dr. Heinz Kabutz explains how you can reduce wasted CPU cycles by implementing a reserved caching scheme. Before a task starts its calculation, it tries to reserve an entry in the shared map. If it is successful, it immediately begins. If not, it blocks until the other thread has finished its calculation. Unfortunately, this might result in a significant number of blocked threads, decreasing CPU utilization.
Make sure you check out our interview with Dr. Heinz Kabutz on the future of Java:
JAXenter: What do you think about Java 9 and project Jigsaw? Is it an important release for Java’s sustainability or is Jigsaw only interesting for specialists?
Dr. Heinz Kabutz: Jigsaw is very important for Java’s future. Even in early versions of Java, the classpath was a mess. The cost of looking for classes was linear, so as the classpath grew, so did the lookup cost. Jigsaw addresses this, plus the security issues that we had in the past. With Jigsaw, we are able to expose classes within a module and restrict access from outside. Performance of synchronized has improved in Java 9.
JAXenter: Where do you think Java is headed? What’s (still) missing? What innovations do you wish to see in the next Java versions (10,11,12…)?
Dr. Heinz Kabutz: We need to work on the garbage collectors to reduce stop-the-world even more. ZGC and Shenandoah look promising. AOT compiling should also make Java start up much faster. We need more built-in parallelism in Java. For example, BigInteger multiply() could use Fork/Join to execute across all the cores.
See the full interview here.