Dr. Heinz Kabutz Is one on the greatest JVM performance gurus, author of the famous Java Specialists news letter and our great friend! We are happy to make this interview with him just before the conference #jPrime2019!
Technical brilliance and Balkan hospitality for a very good price. jPrime is establishing itself as the top independent Java conference in our region. I believe I gave the first talk at the first edition of jPrime. Last year was very frustrating, as I was thwarted by the air traffic controller strike in Athens. The only flight that was cancelled was Athens->Sofia. Let's hope that this year is better.
Well the good news is that our hardware is already running in parallel without us having to do anything. Pipelining and predictive execution FTW. But we can and should take advantage of the many cores that we have available nowadays. Two great tools are CompletableFuture and Fork/Join. And a new one is Project Loom with Fibers.
I'm very hopeful about Project Loom. A couple of years ago at jPrime, I showed how the ManagedBlocker can be used to improve CPU utilization when combined with the Fork/Join pool. Currently there are only a few classes in the JDK that support ManagedBlocker. The two most famous are Phaser and CompletableFuture. This means that when we block with either of these constructs, the ForkJoinPool can create additional threads to pick up the slack. There was talk about including this functionality at the highest level of concurrency, being the AbstractQueuedSynchronizer. However, we are instead moving to Project Loom with Fibers. These support continuations, basically saving the stack of a method call half-way and then allowing it to be restored later. We can create millions of fibers to be run "concurrently" by our system. In reality these would still be executed by default in the common ForkJoinPool. However when a thread is forced to wait, for example when blocking on IO or waiting on an AbstractQueuedSynchronizer, then the fiber gets swapped out and another fiber swapped in. It isn't magic, and please don't believe the smoke and mirror demos that show millions of "sleeps" happening at the same time. We all know that sleeping does not use CPU.
One thing I am concerned about is that Fibers do not give us a good set of idioms that we need to follow. With CompletableFuture, we have an established path to follow if we want to use it for writing concurrent or parallel code. But with fibers we can code as if we were using Threads, but then instead spin the code off to be executed as fibers. This can cause some very funky issues with memory staying reachable for much longer than we intended. Buyer's beware.
In our programming world, we sit far too much. Very few of us have a good excuse. We are, for the most, just plain lazy. I'm the king of laziness. In high school, I used to weasel my way out of any physical activity by claiming to have to do urgent "computer work" for the school. Back in the 80s, no one know what that meant and so you could bamboozle the headmaster. I started running five years ago. I now run every day. I am writing this whilst walking at a treadmill desk. As a young man, I did thousands of pushups in preparation for the South African army. By the time I finished university, Nelson Mandela was in charge and there was no more army conscription. So all those pushups were in vain. However, it did give me good upper body strength. After a long break, I decided to get back into it. But what's the fun of doing this alone? I opened up the challenge to the world. Do 1000 push-ups in October, 2000 in November, all the way until 5000 in February. Every month was hard, and I'm not sure which the worst was. My February started badly as I had a bad cold and had to rest a few days. To catch up, I did 1000 in a single day. By the end of the challenge I looked like Bluto, Popeye's enemy.
All those who completed 15000 push-ups got a big prize to celebrate their achievement, over $15k of prized. I did not tell them up-front that this would happen, as it is just too easy to cheat with over reporting push-ups.
I had another challenge last year where we had to run one mile outside for 40 days in a row, GPS tracked. That was fun too.
My next challenge will probably be a diet experiment. I tried it on myself a few months ago with great success. I will tell you in person when I see you in May at jPrime.
Tsarigradsko Shosse 115B, Sofia, Bulgaria
+359 887 749 325