Supercharge Your Applications with GraalVM: Hands-on examples to optimize and extend your code using GraalVM’s high performance and polyglot capabilities
- Length: 356 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2021-06-30
- ISBN-10: 1800564902
- ISBN-13: 9781800564909
- Sales Rank: #4981721 (See Top 100 Books)
Understand the internals and architecture of GraalVM with the help of hands-on experiments and gain deep knowledge that you can apply to improve your application’s performance, interoperability, and throughput.
Key Features
- 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
Book 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.
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
Who this book is 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.
Table of Contents
- Evolutions of JVM
- JIT, Hotspot, and GraalVM
- GraalVM Architecture
- Graal Compiler – JIT, AOT
- Graal Compiler – Ahead of Time
- Truffle – An overview
- Graal Polyglot (Java, Node)
- GraalVM Polyglot – Java on Truffle, Python and R
- Graal Polyglot – LLVM, Ruby, WASM
- Microservices Framework and ARchitecture with Case Study
Supercharge Your Applications with GraalVM Contributors About the author Preface Who this book is for What this book covers To get the most out of this book Download the example code files Code in Action Download the color images Conventions used Get in touch Reviews Section 1: The Evolution of JVM Chapter 1: Evolution of Java Virtual Machine Technical requirements Introduction to GraalVM Learning how JVM works Understanding the JVM architecture Class loader subsystem Memory subsystem JVM execution engine subsystem Native subsystem Summary Questions Further reading Chapter 2: JIT, HotSpot, and GraalJIT Technical requirements Setup environment Installing OpenJDK Java Installing JITWatch Taking a deep dive into HotSpot and the C2 JIT compiler Code cache Compiler threshold On-stack replacement Tiered compilation Understanding the optimizations performed by JIT Inlining Monomorphic, bimorphic, and megamorphic dispatch Dead code elimination Loop optimization – Loop unrolling Escape analysis Deoptimization Non-entrant code Zombie code Graal JIT and the JVM Compiler Interface (JVMCI) Summary Questions Further reading Section 2: Getting Up and Running with GraalVM – Architecture and Implementation Chapter 3: GraalVM Architecture Reviewing modern architectural requirements Smaller footprint Quicker bootstrap Polyglot and interoperability Learning what the GraalVM architecture is Reviewing the GraalVM editions (Community and Enterprise) Understanding the GraalVM architecture JVM (HotSpot) Java Virtual Machine Compiler Interface (JVMCI) Graal compiler and tooling Truffle Sulong – LLVM SubstrateVM (Graal AOT and native image) An overview of GraalVM microservices architecture Understanding how GraalVM addresses various non-functional aspects Performance and scalability Security DevOps – continuous integration and delivery Summary Questions Further reading Chapter 4: Graal Just-In-Time Compiler Technical requirements Setting up the environment Setting up Graal Understanding the Graal JIT compiler Graal compiler configuration Graal JIT compilation pipeline and tiered optimization Graal intermediate representation Understanding Graal compiler optimizations Speculative optimization Partial escape analysis Inter-procedural analysis and inlining Debugging and monitoring applications Visual Studio Code extension GraalVM Dashboard Command-line tools Chrome debugger Summary Questions Further reading Chapter 5: Graal Ahead-of-Time Compiler and Native Image Technical requirements Building native images Analyzing the native image with GraalVM Dashboard Understanding the code size breakdown report Heap size breakdown Understanding PGO Native image configuration Hosted options and resource configurations Generating Graal graphs for native images Understanding how native images manage memory The Serial garbage collector The G1 Garbage Collector Managing the heap size and generating heap dumps Building static native images and native shared libraries Debugging native images Limitations of Graal AOT (Native Image) GraalVM containers Summary Questions Further reading Section 3: Polyglot with Graal Chapter 6: Truffle – An Overview Exploring the Truffle language implementation framework Exploring the Truffle interpreter/compiler pipeline Self-optimization and tree rewriting Partial Evaluation Learning Truffle DSL Polymorphic inline caching Understanding how Truffle supports interoperability Frame management and local variables Dynamic Object Model Understanding Truffle instrumentation Ahead-of-time compilation using Truffle Optimizing Truffle interpreter performance with launcher options SimpleLanguage and Simple Tool Summary Questions Further reading Chapter 7: GraalVM Polyglot – JavaScript and Node.js Technical requirements Understanding the JavaScript (including Node.js) Truffle interpreter Verifying JavaScript, Node, and npm installation and versions JavaScript interoperability Polyglot native images Bindings Multithreading Asynchronous programming – Promise and await Summary Questions Further reading Chapter 8: GraalVM Polyglot – Java on Truffle, Python, and R Technical requirements Understanding Espresso (Java on Truffle) Why do we need Java on Java? Installing and running Espresso Exploring polyglot interoperability with Espresso Exploring Espresso interoperability with other Truffle languages Understanding GraalPython – the Python Truffle interpreter Installing Graal Python Understanding the graalpython compilation and interpreter pipeline Exploring interoperability between Java and Python Exploring interoperability between Python and other dynamic languages Understanding FastR – the R Truffle interpreter Installing and running R Exploring the interoperability of R Summary Questions Further reading Chapter 9: GraalVM Polyglot – LLVM, Ruby, and WASM Technical requirements Understanding LLVM – the (Sulong) Truffle interface Installing the LLVM toolchain Exploring LLVM interoperability Understanding the LLVM managed environment Understanding TruffleRuby – the Ruby Truffle interpreter Installing TruffleRuby Understanding the TruffleRuby interpreter/compiler pipeline Exploring Polyglot interoperability with TruffleRuby Understanding GraalWasm – the WASM Truffle interpreter Understanding GraalWasm architecture Installing and running GraalWasm Installing Emscripten (emcc) Summary Questions Further reading Section 4: Microservices with Graal Chapter 10: Microservices Architecture with GraalVM Technical requirements Overview of microservices architecture Building microservices architecture with GraalVM Understanding GraalVM containers Case study – online book library Functional architecture Deployment architecture Exploring modern microservices frameworks Building BookInfoService using Spring without GraalVM Building BookInfoService with Micronaut Building BookInfoService with Quarkus Building a serverless BookInfoService using fn project Summary Questions Further reading Assessments Chapter 1 – Evolution of Java Virtual Machine Chapter 2 – JIT, Hotspot, and GraalJIT Chapter 3 – Graal VM Architecture Chapter 4 – Graal Just-In-Time Compiler Chapter 5 – Graal Ahead-of-Time Compiler and Native Image Chapter 6 – Truffle – An Overview Chapter 7 – GraalVM Polyglot – JavaScript and Node.js Chapter 8 – GraalVM Polyglot – Java on Truffle, Python, and R Chapter 9 – GraalVM Polyglot – LLVM, Ruby, and WASM Chapter 10 – Microservices Architecture with GraalVM Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Leave a review - let other readers know what you think
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Supercharge Your Applications with GraalVM: Hands-on examples to optimize and extend your code using GraalVM’s high performance and polyglot capabilities
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.