#9 Project Loom
Static images for the Java Platform. More Java Flight Recorder content. Manage Multiple JDKs. Hacker Folklore
Welcome to the ninth Dukesletter edition!
The AdoptOpenJDK team has released the latest versions of each main distribution (8u252, 11.0.7, and 14.0.1). With which frequency do you update your production servers? if you are deploying using something like Docker, the upgrade is very easy.
The eighth edition was delivered to 431 persons and reached 727 views.
1.- Project Loom
Did you read the latest edition introducing concurrency concepts behind the JVM? I hope so 😀.
To improve resource usage and make your life easier, the JDK team launched Project Loom. Now, if you want to improve the CPU use when you are limited by I/O, you must do other things while waiting in the I/O lock, feeding the CPU with more work.
Feeding with work to the CPU asynchronously, without creating a lot of Threads is complex. Resulting code is difficult to understand and difficult to debug. To avoid it, the promise of Project Loom is:
Codes Like Sync, Works Like Async
To understand the motivation of the project, how are they trying to solve this problem, and with which principles are going to be developed, Ron Pressler wrote the initial proposal and vision: “Project Loom: Fibers and Continuations for the Java Virtual Machine“.
One of the key (and harder) parts of the project is retrofitting existing blocking APIs to become fiber-aware. Each time a thread does blocking I/O, waits on a lock or sleeps, but Fibers will take advantage of the new mechanism, and a blocking I/O call executed on a fiber will use non-blocking I/O under the hood.
I recommend to continue with the following talk by Ron Pressler in the latest Devoxx, where he shows the advances done in the implementation:
One of the building blocks will be Continuations. If it is finally exposed, I expect the creation of new set libraries that will provide alternative and imaginative APIs, which will explore new ways of solving parallelism problems, different than Fibers.
If you are really interested in Project Loom consequences, I encourage you to read “Will Project Loom obliterate Java Futures?” by Adam Warski.
Are we really going to change how we develop with async code?
Fibers are not a solution for orchestrating concurrent flows….
Future
will probably stay, but there’s also a window of opportunity to upgrade the stack and use lazily evaluatedIO
wrappers, bringing even more functional programming to the Java world.
The only clear idea is that it will take time to be ready, and like other critical projects, the JDK team is very cautious and doesn’t want to release something with a problem to regret for the rest of his life.
2.- Static images for the Java Platform
This week Mark Reinhold published a tweet/mail with a Call for Discussion for a new project: Leyden
The idea is similar to what GraalVM proposes (faster startup time and less memory consumption, and less time to peak performance) but from a different point of view, and reusing existing technologies from HotSpot JVM (the jaotc ahead-of-time compiler, application class-data sharing, and the jlink linking tool).
It will also impose restrictions on what your application can do with dynamic bytecode loading/creation.
I don't know yet which is the differential value with respect to GraalVM. Better image generation times?
Both projects will be complementary and will collaborate to standardize how to create static images.
3.- More Java Flight Recorder content
For me, Java Flight Recorder + Java Mission Control are very useful because you don’t need to know a lot about profiling to get insights about your applications. I’m very sensible to news and content about these tools.
This time I highlight:
Java Flight Recorder Coming to OpenJDK 8: JFR was a proprietary solution until Java 11, when Oracle open sourced it. OpenJDK team has backported JDK 8 in production without paying to Oracle.
Which is the impact of this new JFR code in OpenJDK 8 if we activate it? In “Performance impact of JFR on JDK8u” you can see the overhead of JFR in different benchmarks is minimal, and you can activate it in production servers without worrying about penalties.
Flight Recorder API Programmer’s Guide: Oracle documentation is not characterized by its design and usability, but this time they have published a guide about JFR API with a lot of explanations and examples 👏👏. You can also download a PDF with all the content as a book.
4.- Manage Multiple JDKs
Probably in your main production project you still develop and deploy with Java 8, and in side projects or utilities you are using modern JDK versions… which forces you to manage multiple JDK instances. How do you deal with different JDKs installations?
Bruno Borges has written an article explaining the two most used tools to simplify it: “Manage Multiple JDKs on Mac OS, Linux and Windows WSL2“.
Personally, I’m a big fan of SDKMan
5.- Hacker Folklore
Do you know the source of terms like Boilerplate, Core Dump, Cursor, Dashboard, or Foo and Bar variables ?
Matthias Endler has written in his blog a compilation of this and other popular terms in computing: “Hacker Folklore“.
My favorite one is about the origin of the “Radio Button”!