Book Image

Supercharge Your Applications with GraalVM

By : A B Vijay Kumar
Book Image

Supercharge Your Applications with GraalVM

By: A B Vijay Kumar

Overview of this book

GraalVM is a universal virtual machine that allows programmers to compile and run applications written in both JVM and non-JVM languages. It improves the performance and efficiency of applications, making it an ideal companion for cloud-native or microservices-based applications. This book is a hands-on guide, with step-by-step instructions on how to work with GraalVM. Starting with a quick introduction to the GraalVM architecture and how things work under the hood, you'll discover the performance benefits of running your Java applications on GraalVM. You'll then learn how to create native images and understand how AOT (ahead-of-time) can improve application performance significantly. The book covers examples of building polyglot applications that will help you explore the interoperability between languages running on the same VM. You'll also see how you can use the Truffle framework to implement any language of your choice to run optimally on GraalVM. By the end of this book, you'll not only have learned how GraalVM is beneficial in cloud-native and microservices development but also how to leverage its capabilities to create high-performing polyglot applications.
Table of Contents (17 chapters)
1
Section 1: The Evolution of JVM
4
Section 2: Getting Up and Running with GraalVM – Architecture and Implementation
8
Section 3: Polyglot with Graal
13
Section 4: Microservices with Graal

Chapter 2 – JIT, Hotspot, and GraalJIT

  1. A code cache is a special memory area within JVM that is used by JVM to store the compiled code. The code is compiled by JIT compilers and stored in the code cache. If a method is compiled and is found in the code cache, JVM will use that code to run, instead of interpreting the method code. Refer to the Code cache section for more details
  2. The code cache size can be changed using the following flags for fine-tuning. Refer to the Code cache section for more details:

    a. -XX:InitialCodeCacheSize – The initial size of the code cache. The default size is 160 KB (the size varies based on the JVM version)

    b. -XX:ReservedCodeCacheSize – This is the maximum size the code cache can grow to. The default size is 32/48 MB. When the code cache reaches this limit, JVM will throw a warning, CodeCache is full. Compiler has been disabled. JVM offers the UseCodeCacheFlushing option to flush the code cache when the code cache is full....