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 July 2022
JProfiler
|
Get rid of your performance problems and memory leaks!
|
JProfiler
|
Get rid of your performance problems and memory leaks!
|
|
|
Back to newsletter 260 contents
https://www.youtube.com/watch?v=t6vJRZDiT9E
How to adopt Java Flight Recorder to improve non-functional testing (Page last updated December 2019, Added 2022-07-29, Author Marek Bubala, Publisher DevoxxPoland). Tips:
- It's very hard to create fast isolated repeatable validated performance tests.
- A JFR profile specifies what will be recorded, and how often.
- You can use the JFR events to provide consistent performance analysis of tests.
- JMC provides automated analysis of JFR recordings.
https://www.youtube.com/watch?v=qADk_tj4wY8
The Java memory model explained (Page last updated June 2022, Added 2022-07-29, Author Rafael Winterhalter, Publisher JPrime). Tips:
- Code can be reordered for execution. The memory model specifies what can and can't be done by the runtime system in terms of reordering and visibility.
- The runtime system (including the JIT compiler) tries to optimize CPU cache reads and writes, and doing so often causes code element reordering and elimination.
- final and volatile are field scoped modifiers, and synchronized and java.util.concurrent.lock are method-scoped modifiers. volatile ensures that all writes when the volatile field is written are flushed to main memory, and any reads after the volatile field has been read, are from main memory. synchronized is similar, but for code blocks and ensure exclusivity of execution of that code block for a particular monitor.
- Starting a new thread is a memory barrier, so all values written before the thread starts will be visible to the new thread.
- final fields are visible to all threads with the final value.
- JNI calls are considered memory barriers by the compiler because it can't reason about the code in the jni call.
- The most efficient way to initialize a static singleton is by using an enumeration, as enumerations guarantee full initialization.
- Reading and writing conditionally is not atomic on volatile fields, you need to use Atomic* variables.
https://betterprogramming.pub/dealing-with-code-performance-micro-and-macro-optimizations-128269484932
Dealing With Code Performance - Micro and Macro Optimizations (Page last updated June 2022, Added 2022-07-29, Author Ignacio Chiazzo, Publisher Medium). Tips:
- There are two types of Performance optimizations: Micro and Macro Optimizations. Micro optimizations are the most common, tend to have medium to low impact, and have the pattern that the time for fixing the issue is usually short compared to the time spent investigating. Macro optimizations have high scope and effort, and usually makes the platform more complex to understand.
- Micro performance optimization examples include: Caching and batching specific APIs/Models; Removing unnecessary calls; Reducing memory allocations; Removing unnecessary required libraries in the frontend; Reducing the bite-size consumption by the client; Adding Database indexes.
- A common mistake for micro performance optimizations is not preventing the system from having the same performance degradation in the future after maintenance changes. A complete fix would require regression tests that prevent the improvement from degrading by monitoring the performance.
- Macro performance optimization examples include: Introducing a new caching strategy across the platform; New technology (database, library etc.); Database migrations; Models redesigning; Re-architecting the platform.
- Macro performance optimizations that are low impact must be avoided! Micro performance optimizations with high impact are a must-have!
Jack Shirazi
Back to newsletter 260 contents
Last Updated: 2024-11-29
Copyright © 2000-2024 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/newtips260.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us