Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Supercharge Your Applications with GraalVM
Supercharge Your Applications with GraalVM

Supercharge Your Applications with GraalVM: Hands-on examples to optimize and extend your code using GraalVM's high performance and polyglot capabilities

eBook
€22.99 €32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Table of content icon View table of contents Preview book icon Preview Book

Supercharge Your Applications with GraalVM

Chapter 1: Evolution of Java Virtual Machine

This chapter will walk you through the evolution of Java Virtual Machine (JVM), and how it optimized the interpreter and compiler. We will learn about C1 and C2 compilers and various types of code optimizations that the JVM performs to run Java programs faster.

In this chapter, we will cover the following topics:

  • Introduction to GraalVM
  • Learning how JVM works
  • Understanding the JVM architecture
  • Understanding the kind of optimizations JVM performs with Just-In-Time (JIT) compilers
  • Learning the pros and cons of the JVM approach

By the end of this chapter, you will have a clear understanding of the JVM architecture. This is critical in understanding the GraalVM architecture and how GraalVM further optimizes and builds on top of JVM best practices.

Technical requirements

This chapter does not require any specific software/hardware.

Introduction to GraalVM

GraalVM is a high-performance VM that provides the runtime for modern cloud-native applications. Cloud-native applications are built based on the service architecture. The microservice architecture changes the paradigm of building micro applications, which challenges the fundamental way we build and run applications. The microservices runtimes demand a different set of requirements.

Here are some of the key requirements of a cloud-native application built on the microservice architecture:

  • Smaller footprint: Cloud-native applications run on the "pay for what we use" model. This means that the cloud-native runtimes need to have a smaller memory footprint and should run with the optimum CPU cycles. This will help run more workloads with fewer cloud resources.
  • Quicker bootstrap: Scalability is one of the most important aspects of container-based microservices architecture. The faster the application's bootup, the faster it can scale the clusters. This is even more important for serverless architectures, where the code is initialized and run and then shut down on request.
  • Polyglot and interoperability: Polyglot is the reality; each language has its strengths and will continue to. Cloud-native microservices are being built with different languages. It's very important to have an architecture that embraces the polyglot requirements and provides interoperability across languages. As we move to modern architectures, it's important to reuse as much code and logic as possible, that is time-tested and critical for business.

GraalVM provides a solution to all these requirements and provides a common platform to embed and run polyglot cloud-native applications. It is built on JVM and brings in further optimizations. Before understanding how GraalVM works, it's important to understand the internal workings of JVM.

Traditional JVM (before GraalVM) has evolved into the most mature runtime implementation. While it has some of the previously listed requirements, it is not built for cloud-native applications, and it comes with its baggage of monolith design principles. It is not an ideal runtime for cloud-native applications.

This chapter will walk you through in detail how JVM works and the key components of the JVM architecture.

Learning how JVM works

Java is one of the most successful and widely used languages. Java has been very successful because of its write once, run anywhere design principle. JVM realizes this design principle by sitting between the application code and the machine code and interpreting the application code to machine code.

Traditionally, there two ways of running application code:

  • Compilers: Application code is directly compiled to machine code (in C, C++). Compilers go through a build process of converting the application code to machine code. Compilers generate the most optimized code for a specific target architecture. The application code has to be compiled to target architectures. In general, the compiled code always runs faster than interpreted code, and issues with code semantics can be identified during compilation time rather than runtime.
  • Interpreters: Application code is interpreted to machine code line by line (JavaScript and so on). Since interpreters run line by line, the code may not be optimized to the target architecture, and run slowly, compared to the compiled code. Interpreters have the flexibility of writing once and running anywhere. A good example is the JavaScript code that is predominantly used for web applications. This runs pretty much on different target browsers with minimal or no changes in the application code. Interpreters are generally slow and are good for running small applications.

JVM has taken the best of both interpreters and compilers. The following diagram illustrates how JVM runs the Java code using both the interpreter and compiler approaches:

Figure 1.1 – Java compiler and interpreter

Figure 1.1 – Java compiler and interpreter

Let's see how this works:

  • Java Compiler (javac) compiles the Java application source code to bytecode (intermediate format).
  • JVM interprets the bytecode to machine code line by line at runtime. This helps in translating the optimized bytecode to target machine code, helping in running the same application code on different target machines, without re-programming or re-compiling.
  • JVM also has a Just-In-Time (JIT) compiler to further optimize the code at runtime by profiling the code.

In this section, we looked at how Java Compiler and JIT work together to run Java code on JVM at a higher level. In the next section, we will learn about the architecture of JVM.

Understanding the JVM architecture

Over the years, JVM has evolved into the most mature VM runtime. It has a very structured and sophisticated implementation of a runtime. This is one of the reasons why GraalVM is built to utilize all the best features of the JVM and provide further optimizations required for the cloud-native world. To better appreciate the GraalVM architecture and optimizations that it brings on top of the JVM, it's important to understand the JVM architecture.

This section walks you through the JVM architecture in detail. The following diagram shows the high-level architecture of various subsystems in JVM:

Figure 1.2 – High-level architecture of JVM

Figure 1.2 – High-level architecture of JVM

The rest of this section will walk you through each of these subsystems in detail.

Class loader subsystem

The class loader subsystem is responsible for allocating all the relevant .class files and loading these classes to the memory. The class loader subsystem is also responsible for linking and verifying the schematics of the .class file before the classes are initialized and loaded to memory. The class loader subsystem has the following three key functionalities:

  • Loading
  • Linking
  • Initializing

The following diagram shows the various components of the class loader subsystem:

Figure 1.3 – Components of the class loader subsystem

Figure 1.3 – Components of the class loader subsystem

Let's now look at what each of these components does.

Loading

In traditional compiler-based languages such as C/C++, the source code is compiled to object code, and then all the dependent object code is linked by a linker before the final executable is built. All this is part of the build process. Once the final executable is built, it is then loaded into the memory by the loader. Java works differently.

Java source code (.java) is compiled by Java Compiler (javac) to bytecode (.class) files. Class loader is one of the key subsystems of the JVM, which is responsible for loading all the dependent classes that are required to run the application. This includes the classes that are written by the application developer, the libraries, and the Java Software Development Kit (SDK) classes.

There are three types of class loaders as part of this system:

  • Bootstrap: Bootstrap is the first classloader that loads rt.jar, which contains all the Java Standard Edition JDK classes, such as java.lang, java.net, java.util, and java.io. Bootstrap is responsible for loading all the classes that are required to run any Java application. This is a core part of the JVM and is implemented in the native language.
  • Extensions: Extension class loaders load all the extensions to the JDK found in the jre/lib/ext directory. Extension class loader classes are typically extension classes of the bootstrap implemented in Java. The extension class loader is implemented in Java (sun.misc.Launcher$ExtClassLoader.class).
  • Application: The application class loader (also referred to as a system class loader) is a child class of the extension class loader. The application class loader is responsible for loading the application classes in the application class path (CLASSPATH env variable). This is also implemented in Java (sun.misc.Launcher$AppClassLoader.class).

Bootstrap, extension, and application class loaders are responsible for loading all the classes that are required to run the application. In the event where the class loaders do not find the required classes, ClassNotFoundException is thrown.

Class loaders implement the delegation hierarchy algorithm. The following diagram shows how the class loader implements the delegation hierarchy algorithm to load all the required classes:

Figure 1.4 – Class loader delegation hierarchy algorithm implementation flowchart

Figure 1.4 – Class loader delegation hierarchy algorithm implementation flowchart

Let's understand how this algorithm works:

  1. JVM looks for the class in the method area (this will be discussed in detail later in this section). If it does not find the class, it will ask the application class loader to load the class into memory.
  2. The application class loader delegates the call to the extension class loader, which in turn delegates to the bootstrap class loader.
  3. The bootstrap class loader looks for the class in the bootstrap CLASSPATH. If it finds the class, it will load to the memory. If it does not find the class, control is delegated to the extension class loader.
  4. The extension class loader will try to find the class in the extension CLASSPATH. If it finds the class, it will load to the memory. If it does not find the class, control is delegated to the application class loader.
  5. The application class loader will try to look for the class in CLASSPATH. If it does not find it, it will raise ClassNotFoundException, otherwise, the class is loaded into the method area, and the JVM will start using it.

Linking

Once the classes are loaded into the memory (into the method area, discussed further in the Memory subsystem section), the class loader subsystem will perform linking. The linking process consists of the following steps:

  • Verification: The loaded classes are verified for their adherence to the semantics of the language. The binary representation of the class that is loaded is parsed into the internal data structure, to ensure that the method runs properly. This might require the class loader to load recursively the hierarchy of inherited classes all the way to java.lang.Object. The verification phase validates and ensures that the methods run without any issues.
  • Preparation: Once all the classes are loaded and verified, JVM allocates memory for class variables (static variables). This also includes calling static initializations (static blocks).
  • Resolution: JVM then resolves by locating the classes, interfaces, fields, and methods referenced in the symbol table. The JVM might resolve the symbol during initial verification (static resolution) or may resolve when the class is being verified (lazy resolution).

The class loader subsystem raises various exceptions, including the following:

  • ClassNotFoundException
  • NoClassDefFoundError
  • ClassCastException
  • UnsatisfiedLinkError
  • ClassCircularityError
  • ClassFormatError
  • ExceptionInInitializerError

You can refer to the Java specifications for more details: https://docs.oracle.com/en/java/javase.

Initializing

Once all the classes are loaded and symbols are resolved, the initialization phase starts. During this phase, the classes are initialized (new). This includes initializing the static variables, executing static blocks, and invocating reflective methods (java.lang.reflect). This might also result in loading those classes.

Class loaders load all the classes into the memory before the application can run. Most of the time, the class loader has to load the full hierarchy of classes and dependent classes (though there is lazy resolution) to validate the schematics. This is time-consuming and also takes up a lot of memory footprint. It's even slower if the application uses reflection and the reflected classes need to be loaded.

After learning about the class loader subsystem, let's now understand how the memory subsystem works.

Memory subsystem

The memory subsystem is one of the most critical subsystems of the JVM. The memory subsystem, as the name suggests, is responsible for managing the allocated memory of method variables, heaps, stacks, and registers. The following diagram shows the architecture of the memory subsystem:

Figure 1.5 – Memory subsystem architecture

Figure 1.5 – Memory subsystem architecture

The memory subsystem has two areas: JVM level and thread level. Let's discuss each in detail.

JVM level

JVM-level memory, as the name suggests, is where the objects are stored at the JVM level. This is not thread-safe, as multiple threads might be accessing these objects. This explains why programmers are recommended to code thread-safe (synchronization) when they update the objects in this area. There are two areas of JVM-level memory:

  • Method: The method area is where all the class-level data is stored. This includes the class names, hierarchy, methods, variables, and static variables.
  • Heap: The heap is where all the objects and the instance variables are stored.

Thread level

Thread-level memory is where all the thread-local objects are stored. This is accessible/visible to the respective threads, hence it is thread-safe. There are three areas of the thread-level memory:

  • Stack: For each method call, a stack frame is created, which stores all the method-level data. The stack frame consists of all the variables/objects that are created within the method scope, operand stack (used to perform intermediate operations), the frame data (which stores all the symbols corresponding to the method), and exception catch block information.
  • Registers: PC registers keep track of the instruction execution and point to the current instruction that is being executed. This is maintained for each thread that is executing.
  • Native Method Stack: The native method stack is a special type of stack that stores the native method information, which is useful when calling and executing the native methods.

Now that the classes are loaded into the memory, let's look at how the JVM execution engine works.

JVM execution engine subsystem

The JVM execution engine is the core of the JVM, where all the execution happens. This is where the bytecodes are interpreted and executed. The JVM execution engine uses the memory subsystem to store and retrieve the objects. There are three key components of the JVM execution engine, as shown:

Figure 1.6 – JVM execution engine architecture

Figure 1.6 – JVM execution engine architecture

We will talk about each component in detail in the following sections.

Bytecode interpreter

As mentioned earlier in this chapter, bytecode (.class) is the input to the JVM. The JVM bytecode interpreter picks each instruction from the .class file and converts it to machine code and executes it. The obvious disadvantage of interpreters is that they are not optimized. The instructions are executed in sequence, and even if the same method is called several times, it goes through each instruction, interprets it, and then executes.

JIT compiler

The JIT compiler saves the day by profiling the code that is being executed by interpreters, identifies areas where the code can be optimized and compiles them to target machine code, so that they can be executed faster. A combination of bytecode and compiled code snippets provide the optimum way to execute the class files.

The following diagram illustrates the detailed workings of JVM, along with the various types of JIT compilers that the JVM uses to optimize the code:

Figure 1.7 – The detailed working of JVM with JIT compilers

Figure 1.7 – The detailed working of JVM with JIT compilers

Let's understand the workings shown in the previous diagram:

  1. The JVM interpreter steps through each bytecode and interprets it with machine code, using the bytecode to machine code mapping.
  2. JVM profiles the code consistently using a counter, to count the number of times a code is executed, and if the counter reaches a threshold, it uses the JIT compiler to compile that code for optimization and stores it in the code cache.
  3. JVM then checks whether that compilation unit (block) is already compiled. If JVM finds a compiled code in the code cache, it will use the compiled code for faster execution.
  4. JVM uses two types of compilers, the C1 compiler and the C2 compiler, to compile the code.

As illustrated in Figure 1.7, the JIT compiler brings in optimizations by profiling the code that is running and, over a period of time, it identifies the code that can be compiled. The JVM runs the compiled snippets of code instead of interpreting the code. It is a hybrid method of running interpreted code and compiled code.

JVM introduced two types of compilers, C1 (client) and C2 (server), and the recent versions of JVM use the best of both for optimizing and compiling the code at runtime. Let's understand these types better:

  • C1 compiler: A performance counter was introduced, which counted the number of times a particular method/snippet of code is executed. Once a method/code snippet is used a particular number of times (threshold), then that particular code snippet is compiled, optimized, and cached by the C1 compiler. The next time that code snippet is called, it directly executes the compiled machine instructions from the cache, rather than going through the interpreter. This brought in the first level of optimization.
  • C2 compiler: While the code is getting executed, the JVM will perform runtime code profiling and come up with code paths and hotspots. It then runs the C2 compiler to further optimize the hot code paths. This is also known as a hotspot.

C1 is faster and good for short-running applications, while C2 is slower and heavy, but is ideal for long-running processes such as daemons and servers, so the code performs better over time.

In Java 6, there is a command-line option to use either C1 or C2 methods (with the command-line arguments -client (for C1) and -server (for C2)). In Java 7, there is a command-line option to use both. Since Java 8, both C1 and C2 compilers are used for optimization as the default behavior.

There are five tiers/levels of compilation. Compilation logs can be generated to understand which Java method is compiled using which compiler tier/level. The following are the five tiers/levels of compilation:

  • Interpreted code (level 0)
  • Simple C1 compiled code (level 1)
  • Limited C1 compiled code (level 2)
  • Full C1 compiled code (level 3)
  • C2 compiled code (level 4)

Let's now look at the various types of code optimizations that the JVM applies during compilation.

Code optimizations

The JIT compiler generates the internal representation of the code that is being compiled to understand the semantics and syntax. These internal representations are tree data structures, on which the JIT will then run the code optimization (as multiple threads, which can be controlled with the XcompilationThreads options from the command line).

The following are some of the optimizations that the JIT compilers perform on the code:

  • Inlining: One of the most common programming practices in object-oriented programming is to access the member variables through getter and setter methods. Inlining optimization replaces these getter/setter methods with actual variables. The JVM also profiles the code and identifies other small method calls that can be inlined to reduce the number of method calls. These are known as hot methods. A decision is taken based on the number of times that the method is called and the size of the method. The size threshold used by JVM to decide inlining can be modified using the -XX:MaxFreqInlineSize flag (by default, it is 325 bytes).
  • Escape analysis: The JVM profiles the variables to analyze the scope of the usage of the variables. If the variables don't escape the local scope, it then performs local optimization. Lock Elision is one such optimization, where the JVM decided whether a synchronization lock is really required for the variable. Synchronization locks are very expensive to the processor. The JVM also decides to move the object from the heap to the stack. This has a positive impact on memory usage and garbage collection, as the objects are destroyed once the method is executed.
  • DeOptimization: DeOptimization is another critical optimization technique. The JVM profiles the code after optimization and may decide to deoptimize the code. Deoptimizations will have a momentary impact on performance. The JIT compiler decides to deoptimize in two cases:

    a. Not Entrant Code: This is very prominent in inherited classes or interface implementations. JIT may have optimized, assuming a particular class in the hierarchy, but over time when it learns otherwise, it will deoptimize and profile for further optimization of more specific class implementations.

    b. Zombie Code: During Not Entrant code analysis, some of the objects get garbage collected, leading into code that may never be called. This code is marked as zombie code. This code is removed from the code cache.

Apart from this, the JIT compiler performs other optimizations, such as control flow optimization, which includes rearranging code paths to improve efficiency and native code generation to the target machine code for faster execution.

JIT compiler optimizations are performed over a period of time, and they are good for long-running processes. We will be going into a detailed explanation on JIT compilation in Chapter 2, JIT, Hotspot, and GraalVM.

Java ahead-of-time compilation

The ahead-of-time compilation option was introduced with Java 9 with jaotc, where a Java application code can be directly compiled to generate final machine code. The code is compiled to a target architecture, so it is not portable.

Java supports running both Java bytecode and AOT compiled code together in an x86 architecture. The following diagram illustrates how it works. This is the most optimum code that Java can generate:

Figure 1.8 – The detailed workings of JVM JIT time compilers along with the ahead-of-time compiler

Figure 1.8 – The detailed workings of JVM JIT time compilers along with the ahead-of-time compiler

The bytecode will go through the approach that was explained previously (C1, C2). jaotc compiles the most used java code (like libraries) into machine code, ahead of time, and this is directly loaded into the code cache. This will reduce the load on JVM. The Java byte code goes through the usual interpreter, and uses the code from the code cache, if available. This reduces a lot of load on JVM to compile the code at runtime. Typically, the most frequently used libraries can be AOT compiled for faster responses.

Garbage collector

One of the sophistication of Java is its in-built memory management. In languages such as C/C++, the programmer is expected to allocate and de-allocate the memory. In Java, JVM takes care of cleaning up the unreferenced objects and reclaims the memory. The garbage collector is a daemon thread that performs the cleanup either automatically or can also be invoked by the programmer (System.gc() and Runtime.getRuntime().gc()).

Native subsystem

Java allows programmers to access native libraries. Native libraries are typically those libraries that are built (using languages such as C/C++) and used for a specific target architecture. Java Native Interface (JNI) provides an abstraction layer and interface specification for implementing the bridge to access the native libraries. Each JVM implements JNI for the specific target system. Programmers can also use JNI to call the native methods. The following diagram illustrates the components of the native subsystem:

Figure 1.9 – Native subsystem architecture

Figure 1.9 – Native subsystem architecture

The native subsystem provides the implementation to access and manage the native libraries.

JVM has evolved and has one of the most sophisticated implementations of a language VM runtime.

Summary

In this chapter, we started by learning what GraalVM is, followed by understanding how JVM works and its architecture, along with its various subsystems and components. Later on, we also learned how JVM combines the best of interpreters and the compiler approach to run Java code on various target architectures, along with how a code is compiled just-in-time with C1 and C2 compilers. Lastly, we learned about various types of code optimizations that the JVM performs.

This chapter provided a good understanding of the architecture of JVM, which will help us understand how the GraalVM architecture works and how it is built on top of JVM.

The next chapter will cover the details of how JIT compilers work and help you understand how Graal JIT builds on top of JVM JIT.

Questions

  1. Why is Java code interpreted to bytecode and later compiled at runtime?
  2. How does JVM load the appropriate class files and link them?
  3. What are the various types of memory areas in JVM?
  4. What is the difference between the C1 compiler and the C2 compiler?
  5. What is a code cache in JVM?
  6. What are the various types of code optimizations that are performed just in time?

Further reading

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Generate faster and leaner code with minimum computing resources for high performance
  • Compile Java applications faster than ever to a standalone executable called native images
  • Create high-performance polyglot applications that are compatible across various JVM and non-JVM languages

Description

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.

Who is this book for?

This book is for JVM developers looking to optimize their application's performance. You'll also find this book useful if you're a JVM developer looking to explore options to develop polyglot applications using tools from the Python, R, Ruby, or Node.js ecosystem. A solid understanding of software development concepts and prior experience working with programming languages is necessary to get started.

What you will learn

  • Gain a solid understanding of GraalVM and how it works under the hood
  • Work with GraalVM s high performance optimizing compiler and see how it can be used in both JIT (just-in-time) and AOT (ahead-of-time) modes
  • Get to grips with the various optimizations that GraalVM performs at runtime
  • Use advanced tools to analyze and diagnose performance issues in the code
  • Compile, embed, run, and interoperate between languages using Truffle on GraalVM
  • Build optimum microservices using popular frameworks such as Micronaut and Quarkus to create cloud-native applications
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Aug 10, 2021
Length: 360 pages
Edition : 1st
Language : English
ISBN-13 : 9781800564909
Category :
Languages :
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Product feature icon AI Assistant (beta) to help accelerate your learning
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

Product Details

Publication date : Aug 10, 2021
Length: 360 pages
Edition : 1st
Language : English
ISBN-13 : 9781800564909
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 114.97
Supercharge Your Applications with GraalVM
€41.99
Modern API Development with Spring and Spring Boot
€36.99
Designing Hexagonal Architecture with Java
€35.99
Total 114.97 Stars icon
Banner background image

Table of Contents

16 Chapters
Section 1: The Evolution of JVM Chevron down icon Chevron up icon
Chapter 1: Evolution of Java Virtual Machine Chevron down icon Chevron up icon
Chapter 2: JIT, HotSpot, and GraalJIT Chevron down icon Chevron up icon
Section 2: Getting Up and Running with GraalVM – Architecture and Implementation Chevron down icon Chevron up icon
Chapter 3: GraalVM Architecture Chevron down icon Chevron up icon
Chapter 4: Graal Just-In-Time Compiler Chevron down icon Chevron up icon
Chapter 5: Graal Ahead-of-Time Compiler and Native Image Chevron down icon Chevron up icon
Section 3: Polyglot with Graal Chevron down icon Chevron up icon
Chapter 6: Truffle for Multi-language (Polyglot) support Chevron down icon Chevron up icon
Chapter 7: GraalVM Polyglot – JavaScript and Node.js Chevron down icon Chevron up icon
Chapter 8: GraalVM Polyglot – Java on Truffle, Python, and R Chevron down icon Chevron up icon
Chapter 9: GraalVM Polyglot – LLVM, Ruby, and WASM Chevron down icon Chevron up icon
Section 4: Microservices with Graal Chevron down icon Chevron up icon
Chapter 10: Microservices Architecture with GraalVM Chevron down icon Chevron up icon
Assessments Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Full star icon 5
(21 Ratings)
5 star 95.2%
4 star 4.8%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




sangeeth Kumar Aug 10, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I got a previledge to be the early reader of such a wonder book! Here is my review..When I read the last page of the book, I realised that the very old idiom "don't judge a book by its cover" applies so good to this book. This book is much more than what the title/ cover tells. I would probably name it as - "Super charge your brain with GraalVM".The author has beautifully orchestrated the chapters like a story. Recommendation to the readers is to start from the beginning to enjoy the journey, rather than jumping to the specific topic by checking index.About the content and the very subject "GraalVM & its performance", this book not only explains 'what and how', but also ‘why' by explaining the fundamentals such as role of C1, C2 compilers, JIT, AHOTs etc to the detailed possible way. Author also has provided the visuals & installations steps wherever applicable. so we not only read and understand but also easily replicate it ourself to validate the same. I liked the fact that every section have some kind of repeated reference & details to previous chapters as we read forward - which actual helps to refresh the memory and relate the concepts with better understanding.Another cool thing is the usage of language -Though the subject is pretty new and complex, I find it easy to understand and grasp - Thanks to usage of simple english words and common vocabularies. Simple and elegant block diagrams are very useful.I started reading this book presuming that I would get an idea of what is Graal VM & how to use it. But when I finished, the learning was beyond the GraalVM. Got a different perspective about Java language itself. Most of the popular language integration with polyglot support are individually explained in detail. So you are not only left with one example to get an idea and figure out yourself how to do the same for other language.I recommend this book not only to the developers & architects who are into cloud & micro-service world, but even to the front end developers with basic Java knowledge, because you will learn the fundamentals even better. Lastly, even if you are someone not interested in basics and just want - 'know how’, read the last few chapters which explains in details - how to install and deploy the services with GraalVM. At the end, I am supercharged!! Happy reading.
Amazon Verified review Amazon
Jermaine Feb 08, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
It was refreshing to read the practical usage of GraalVM in the context of Cloud-Native microservices. The book provided a great introduction to GraalVM and how GraalVM can be leveraged with polyglot technology such as NodeJS and Java to optimize microservice applications. I enjoyed the hands-on examples to showcase simple and complex use cases, including a microservice case study example. Overall, the book is an excellent read for software engineers and architects looking for hands-on learning of GraalVM.
Amazon Verified review Amazon
Naveen Purushothaman Aug 11, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Lucky to receive an early copy of the book.The book starts by providing an overview of JVM evolution and provides a good introduction to JVM. Then it is a real deep journey to GraalVM. However, one key thing to note is the special focus from the author to keep the complex simple. Easy to understand diagrams and textual explanation makes it a real joy to read the book. Moreover, the hands-on exercises and accompanying detailed explanations keeps everything grounded. Technology moves very fast and it is not so often we see a book like this, which is covering everything around the relatively new technology so comprehensively. I strongly feel that this GraalVM bible should be prescribed as a text book for students focused at computer science.
Amazon Verified review Amazon
Gokul Alex Mar 12, 2022
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I am amazed at the bewildering variety of compiler techniques covered by this book. It is written in a direct and dynamic language that makes the book quite accessible to every engineer who has used Java Programming language at least once. This book is written with enough details so that we can consider it as an essential reference on Graal VM and its internal elements. Graal VM has achieved the goal of writing a Java Virtual Machine in Java itself, aiming to address the problems inherited from its roots in C++ such as memory leaks. Graal Graph is really an exciting idea that I have come across in this book. AST Rewriting and Partial Evaluation are quite interesting. Polyglot APIs are empowering Java to embed languages such as R to perform statistical and machine learning programs. The exotic combination of Truffle and Graal promises a new world of interoperability. Some of the concepts used by GraalVM such as partial evaluations are intimately connected to the revolutionary programming languages such as Lisp. Identification of new data types through profiling is indeed a novel idea. As we get into the final chapter on how GraalVM is a great choice for microservices architecture through its common runtime, multiple language support and interoperability, it reaches a meaningful conclusion. It is also nice to see how GraalVM provides security for micro services through its sandbox model. All together this book is an exciting journey into the exotic world of polyglot programming and powerful optimisations.
Amazon Verified review Amazon
Amazon Customer Oct 08, 2021
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Different from other books that teach you how to build web services, this book takes an unconventional path and starts from JVM -- the "engine" of the entire application stack. Explaining how different parts of JVM affects overall performance and how GraalVM stands out in these key sectors, compared to HotSpot VM, the default JVM came with JDK. I personally found this part of the book most interesting. Another highlight in later chapters is the introduction to different programming languages supported by GraalVM. Which gives a practical guide for engineers to adopt these runtimes and really shows GraalVM's versatility.Overall it's an useful and insightful book for developers and power users to build high-performance microservices.Note: I received this book for free.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela