Sunday, February 22, 2026

Concurrent Garbage Collector

 It uses multiple threads to perform GC. Concurrent means the collector can run simultaneously with application threads. Therefore the system must have enough cpu for best result. Compaction still stop the application threads. 

Serial Garbage Collector

It uses a single thread to perform GC. It is best use for a system with single cpu (container) or mainly for batch. It is also used in client ends. 

GC and heap

Steps include scan the heap, mark those objects that are in used and compact the heap. Heap is divided into young and old generation. The young region contains the eden and a several survival spaces. The minor GC clean up the young region. It stops all active threads for a short moment due to the smaller size of eden. The full GC is triggered when the tenure space is full. 

Monday, February 16, 2026

AOT compilation

Ahead of time compiler create a share library (so) format  for JVM to load at start up time. This intended to shorten the start up time of system. The optimisation is C1 level. The code can be recompiled to c2 level later. 

Friday, February 13, 2026

Java OSR

Compilation in java is fine asynchronously. Java code will continue to be executed via interpretation while the compilation is queued to compile. Once compilation is done, the compile code will replace the Java’s code o. The stack so that the next execution of the code path will use the compiled code instead. This is called on stack replacement. For example, if the code to be compiled is a loop that keep on running. You cannot wait to replace the java  code by compiled code until the loop execution ends which may never happened. OSR enable the compiled code to run as soon as the compilation is done. 

Java tier compilation

Java has 2 compilers - C1 abs C2. C1 originated from client jvm and C2 from server jvm. C1 is more aggressive in the sense that it started to compile code earlier than C2. C2 observes the execution longer before compilation and generated more optimised code than C1. This made sense in the past as client code tends to run shorter and thus earlier compilations will be beneficial. Server side code tends to run longer and a more optimized code is beneficial in long run. 

Presently, jvm uses both C1 and C2 compiler. It is called tiered compilation. Code will be first compiled with C1 and hotter code will then recompile with C2

Java code cache

When the code cache is filled up, Iava JIT compilation would stop. This could affect performance as hot code will remained being interpreted.