Client, Server and Tiered Compilation

Client and Server Compilers

There are two basic types of Just-In-Time Java compilers: Client and Server. Traditionally, the Client and the Server compilers are called C1 and C2 respectively.


The main difference between the Client and the Server compilers is the aggressiveness in a way they compile code. The Client compiler is optimised to make application startup faster, whereas Server compiler gives better performance in the long run. As you might have guessed, the Client compiler is dedicated to any type of client application (usually GUI-based), where Server compiler is designed for long-running server side applications.


Why is the Server compiler faster eventually? It’s because the Server compiler observers and analyses the code for a longer period of time and that knowledge allows the Server compiler to make better optimisations in the compiled code. On the contrary, the Client compiler tries to optimise and compile code as soon as possible which makes the startup time lower.


The obvious question you might ask is whether it’s possible to make a mix of both the Client and the Server compilers to have both fast startup and as good performance as possible in the long run? The good answer is yes, we can have it since Java 7 and it’s called Tiered compilation.


Tiered Compilation

With Tiered compilation, the Client compiler is used at the beginning to make startup fast, then when the code becomes hot, it is recompiled by the Server compiler. Click here to learn more about Tiered Compilation and where the name came from.


In Java 8, Tiered compilation is enabled by default.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.