Java Performance Tuning
Java(TM) - see bottom of page
Our valued sponsors who help make this site possible
JProfiler: Get rid of your performance problems and memory leaks!
Training online: Concurrency, Threading, GC, Advanced Java and more ...
Tips February 2025
JProfiler
|
Get rid of your performance problems and memory leaks!
|
JProfiler
|
Get rid of your performance problems and memory leaks!
|
|
|
Back to newsletter 291 contents
https://www.youtube.com/watch?v=QDk1c0ifoNo
Java 24 Stops Pinning Virtual Threads (Almost) (Page last updated November 2024, Added 2025-02-26, Author Nicolai Parlog, Publisher Java). Tips:
- Virtual threads are lightweight threads managed by the JVM, not the OS. They are mounted onto and unmounted from carrier/platform threads in a dedicated pool. Unmounting occurs when a virtual thread blocks, freeing the carrier thread for other tasks. Pinning and capturing are mechanisms that can prevent this unmounting, impacting scalability.
- Prior to JDK 24, virtual threads were pinned to carrier threads within synchronized blocks and during Object::wait to ensure monitor correctness, impacting scalability. JDK 24 resolves this by having the monitor mechanism track virtual thread IDs, eliminating the need for pinning in these cases. Virtual threads are still pinned when calling native code (e.g., C libraries). Class loading causes native code calls, so class initialization will cause pinning.
- jdk.VirtualThreadPinned JDK Flight Recorder event can be used to monitor virtual thread pinning.
- File system operations can capture carrier threads, meaning they can block during I/O (this is different from network I/O where the operations have been reimplemented since JDK 21 to not block carrier threads when virtual threads are blocked on I/O). This file I/O carrier thread capturing (blocking) remains an issue in JDK24.
https://www.happycoders.eu/java/ahead-of-time-class-loading-and-linking/
Ahead-of-Time Class Loading & Linking - Turbo for Java Applications (Page last updated December 2024, Added 2025-02-26, Author Sven Woltmann, Publisher HappyCoders). Tips:
- Java application startup can be slow due to dynamic class loading, initialization, and framework overhead (unpacking JARs, analyzing classes, annotation scanning, bean instantiation).
- Ahead-of-Time (AoT) class loading & linking is a new feature (in Java 24) that caches some startup tasks in a binary file after startup phases of reading, parsing, loading, and linking, significantly speeding up subsequent starts.
- Ahead-of-Time (AoT) class loading & linking works by: 1 a training run that generates the cache startup configuration; 2 which is stored into a file; and 3 subsequent startups load the classes directly from the cache in a loaded and linked state.
- To use Ahead-of-Time (AoT) class loading & linking: 1 start the training run with options -XX:AOTMode=record -XX:AOTConfiguration=SOME_CONF_FILENAME; 2 create the cache with -XX:AOTMode=create -XX:AOTConfiguration=SOME_CONF_FILENAME -XX:AOTCache=SOME_CACHE_FILENAME; 3. use the cache file in subsequent runs with -XX:AOTCache=SOME_CACHE_FILENAME.
- The difference between Ahead-of-Time class loading & linking and (Application) Class Data Sharing is that: (Application) Class Data Sharing reads and parses the classes and then stores them in a binary format; while with AoT Class loading & linking the classes are additionally loaded into Class objects and linked.
https://medium.com/@sibiponkumar/project-leyden-enhancing-javas-adaptability-and-consistency-in-modern-cloud-native-environments-cbed8750db1c
Project Leyden: Enhancing Java's Adaptability and Consistency in Modern Cloud-Native Environments (Page last updated October 2024, Added 2025-02-26, Author Sibiponkumar Balaji, Publisher Medium). Tips:
- Summary of AOT options: -XX:AOTMode=record enables configuration recording during a training run; -XX:AOTMode=create generates the cache based on recorded configuration; -XX:AOTConfiguration specifies the path to the AOT configuration file; -XX:AOTCache specifies the path to the AOT cache file; -XX:AOTMode values on/off enables or disables using the AOT cache.
- To make the most of AOT caching: make sure your training run matches production settings, including the same JDK version, class paths, and module configurations; limit the training run to scenarios that load only necessary classes; avoid large tests or unused classes in the training run that may bloat the cache size with unnecessary classes; mock external dependencies in the training run (like databases or network calls) to prevent loading additional classes that are not needed in production.
Jack Shirazi
Back to newsletter 291 contents
Last Updated: 2025-02-25
Copyright © 2000-2025 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. JavaPerformanceTuning.com is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
URL: http://www.JavaPerformanceTuning.com/news/newtips291.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us