RSSAmplifier

Blog

Minborg's Java Pot

This is my Java blog with various tips and tricks that are targeted for medium and advanced Java users. I work as a Java Core Library Developer at Oracle. The views on this blog are my own and are not necessarily the ones of Oracle, Inc. Happy Reading! /Per Minborg

minborgsjavapot.blogspot.comRSS feed ↗25 posts

Latest posts

Statistics for the 1BRC Java Challenge

Introduction It is hard to avoid hearing about Gunnar Morling’s "One Billion Row Challenge" these days, where the objective is to parse and compute the min, average and max value for various weather stations using the Java language. The data to analyze is a semicolon-separated list of rows that looks like this: Hamburg;12.0 Bulawayo;8.9 Palembang;38.8 St. John's;15.2 Cracow;12.6 Bridgetown;26.9…

My Presentations at Devoxx BE 2023

Presentations at Devoxx BE October 2023 I did two presentations at Devoxx and also participated in the "Ask the Java Architects" presentation. Here are the videos of the presentations: Ask the Java Architects By Sharat Chander, Alan Bateman, Stuart Marks, Viktor Klang, Brian Goetz, and Per Minborg With Java 21, Your Code Runs Even Faster But How Is That Possible? By Per Minborg The Panama Dojo:…

Java Records are "Trusted" and Consequently Faster

Java Records are "Trusted" and Consequently Faster Did you know Java records are trusted by the Hotspot VM in a special way? This makes their speed superior in some aspects compared to regular Java classes. In this short article, we will take a look at constant folding of instance fields and how this can bolster the performance of your Java application. Background Suppose we want to model an…

Java 22: Panama FFM Provides Massive Performance Improvements for Native Strings

Java 22: Panama FFM Provides Massive Performance Improvements for Native Strings The Panama Foreign Function and Memory (FFM) API is slated to be finalized in Java 22 and will then be a part of the public Java API. One thing that is perhaps less known is the significant performance improvements made by FFM in certain areas in 22. In this short article, we will be looking at benchmarking string…

Java: New Draft JEP: "Computed Constants"

Java: JEP Draft: "Computed Constants" We finally made the draft JEP "Computed Constants" public and I can’t wait to tell you more about it! ComputedConstant objects are superfast immutable value holders that can be initialized independently of when they are created. As an added benefit, these objects may in the future be even more optimized via "condensers" that eventually might become available…

Video: Project Panama and the Foreign Function and Memory API

The “Foreign Function and Memory API” (FFM), previewed in Java 20, allows Java programs to interoperate safely with code and data outside the Java runtime. In this fast-paced talk, we will explore what the FFM API has to offer and, via a hands-on live coding example, see how the promises of FFM can be realized in your code today. The live-code example involves integrating and using a native system…

JDK 21: Image Performance Improvements

Introduction In a previous article , I talked about how serialization and file I/O performance was improved in JDK 21 thanks to the use of VarHandle constructs. The method employed there has now also been applied to Java’s image-handling library making it faster. Here is what happened: Background When packing/unpacking primitive values (such as int and long primitives) into/from a byte array,…

Java 21: Performance Improvements Revealed

In Java 21, old code might run significantly faster due to recent internal performance optimizations made in the Java Core Libraries. In this article, we will take a closer look at some of these changes and see how much faster your favorite programming language has become. Buckle up, for we are about to run at full speed! Background When converting primitive values such as int and long values back…

Java 20: An Almost Infinite Memory Segment Allocator

Wouldn’t it be cool if you could allocate an infinite amount of memory? In a previous article , I elaborated a bit on how to create memory-mapped files which could be sparse. In this article, we will learn how this can be leveraged as an under-carriage for providing a memory-allocating arena that can return an almost infinite amount of native memory without ever throwing an OutOfMemoryError .…

Java 20: Colossal Sparse Memory Segments

Did you know you can allocate memory segments that are larger than the physical size of your machine’s RAM and indeed larger than the size of your entire file system? Read this article and learn how to make use of mapped memory segments that may or may not be “sparse” and how to allocate 64 terabytes of sparse data on a laptop. Mapped Memory Mapped memory is virtual memory that has been assigned a…

Java 20: A Sneak Peek on the Panama FFM API (Second Preview)

The new JEP 434 has just seen daylight and describes the second preview of the ”Foreign Function & Memory API” (or FFM for short) which is going to be incorporated in the upcoming Java 20 release! In this article, we will take a closer look at some of the improvements made from the first preview that debuted in Java 19 via the older JEP 424 . Getting familiar with the FFM This article assumes you…

Exhaustive JUnit5 Testing with Combinations, Permutations and Products

Exhaustive JUnit5 Testing with Combinations, Permutations, and Products Unit testing constitutes an integral part of the process of providing high-quality software. But, how can one write tests covering all variants of several operations? Read this article and learn how to use JUnit5 in conjunction with combinations, permutations, and products. Test Support Libraries There are many libraries that…

Which JVM Version is Fastest?

Which JVM Version is Fastest? How is a high-performance, low-latency Java application affected by the JVM version used? Every nanosecond counts for trading and other applications where messages between two different threads are exchanged in about 250 ns! Read this article and find out which JDK variant comes out at the top! Benchmarks This article will use open-source Chronicle Queue to exchange…

How to Reduce Cloud Cost by 99% for EDA Kafka Applications

How to Reduce Cloud Cost by 99% for EDA Kafka Applications While the cloud offers great convenience and flexibility, the operational cost for applications deployed in the cloud can sometimes be significant. This article shows a way to substantially reduce operating costs in latency-sensitive Event-Driven Architecture (EDA) Java applications by migrating from Kafka to Chronicle Queue open-source, a…

Did You Know the Fastest Way of Serializing a Java Field is not Serializing it at All?

Did You Know the Fastest Way of Serializing a Java Field is not Serializing it at All? This article elaborates on different ways of serializing Java objects and benchmarks performance for the variants. Read this article and become aware of different ways to improve Java serialization performance. In a previous article about open-source Chronicle Queue , there was some benchmarking and method…

How the Java Language Could Better Support Composition and Delegation

How the Java Language Could Better Support Composition and Delegation This article outlines a way of improving the Java language to better support composition and delegation. Engage in the discussion and contribute to evolving the Java Language. The Java language lacks explicit semantic support for composition and delegation. This makes delegating classes hard to write, error-prone, hard to read…

Java: How Object Reuse Can Reduce Latency and Improve Performance

Java: How Object Reuse Can Reduce Latency and Improve Performance Become familiar with the art of object reuse by reading this article and learn the pros and cons of different reuse strategies in a multi-threaded Java application. This allows you to write more performant code with less latency. While the use of objects in object-oriented languages such as Java provides an excellent way of…

Java: Creating Terabyte Sized Queues with Low-Latency

Queues are often fundamental components in software design patterns. But, what if there are millions of messages received every second and multi-process consumers need to be able to read the complete ledger of all messages? Java can only hold so much information before the heap becomes a limiting factor with high-impacting garbage collections as a result, potentially preventing us from fulfilling…

Java: Why a Set Can Contain Duplicate Elements

Java: Why a Set Can Contain Duplicate Elements In low-latency applications, the creation of unnecessary objects is often avoided by reusing mutable objects to reduce memory pressure and thus the load on the garbage collector. This makes the application run much more deterministically and with much less jitter. However, care must be taken as to how these reused objects are used or else unexpected…

Why General Inheritance is Flawed and How to Finally Fix it

Why General Inheritance is Flawed and How to Finally Fix it By leveraging composition and the final keyword in the right way, you can improve your programming skills and become a better Java programmer. General inheritance, whereby a public class is extended over package boundaries, provides a number of challenges and drawbacks and should be avoided in almost all cases. Classes and methods can be…

Java: Creating Terabyte Sized Queues with Low-Latency

Queues are often fundamental components in software design patterns. But, what if there are millions of messages received every second and multi-process consumers need to be able to read the complete ledger of all messages? Java can only hold so much information before the heap becomes a limiting factor with high-impacting garbage collections as a result, potentially preventing us from fulfilling…

Did You Know You Can Create Mappers Without Creating Underlying Objects in Java?

As most Java developers know, putting values in a Java Map (like a HashMap ) involves creating a large number of auxiliary objects under the covers. For example, a HashMap with int keys and long values might, for each entry, create a wrapped Integer , a wrapped Long object and a Node that holds the former values together with a hash value and a link to other potential Node objects sharing the same…

How to get Type-Safe and Intuitive Hibernate/JPA Queries by Leveraging Java Streams

A large proportion of Java database applications are using Hibernate/JPA to bridge the gap between Java and SQL. Until recently, we were forced to mix Java and JPQL or to use complex imperative criteria builders to create database queries. Both of these methods are inherently neither type-safe nor very intuitive. The newly launched open-source library JPAstreamer addresses these issues by allowing…

Extend Hibernate to Handle Java Stream Queries

The Java Stream API released in Java 8 has proven itself to be an efficient, terse yet intuitive way of expressing application logic. The newly launched open-source project JPAstreamer allows you to express Hibernate or other JPA database queries using Java Streams. In this article, we will show you how to extend the API of your existing database applications to handle Stream queries in an…

Java/Cloud: How to Quickly Create a Kubernetes-ready REST Microservice

Java/Cloud: How to Quickly Create a Kubernetes-ready REST Microservice It is safe to say that the Microservice + Cloud combination is all the rage these days. Microservices are being developed more than ever, in turn resulting in an increase in the number of application deployments. During the past decade, containerization and orchestration tools such as Docker and Kubernetes were developed,…