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 October 2021
JProfiler
|
Get rid of your performance problems and memory leaks!
|
JProfiler
|
Get rid of your performance problems and memory leaks!
|
|
|
Back to newsletter 251 contents
https://www.youtube.com/watch?v=5nN1wjA_S30
Computing Performance: On the Horizon (Page last updated June 2021, Added 2021-10-29, Author Brendan Gregg, Publisher Usenix). Tips:
- Workloads have become memory bound - CPUs spend most of their time waiting for data to reach them, rather than processing that data. This means you often need to focus on optimizing getting data to the CPU to get speedups. Focus on "Instructions per cycle" - production workloads should be around 1.5 if efficient. Note that a stalled CPU is still reported as 100% utilized by the metric.
- Make sure you are monitoring the GPU, FPGA and TPU processing utilization as well as your CPU - they all count towards overall processing efficiency.
- Core counts are always increasing, your app should be designed to be able to use up to 1000 threads to scale throughout for full efficiency.
- Increasing core variety means your application might run much more efficiently on some core architectures than others - so benchmarks on the wrong CPU architectures are all but useless.
- The Linux Kyber IO scheduler can significantly improve IO performance.
- Newer TCP congestion control algorithms, like TCP BBR, are worth trying.
- See if you can co-locate microservices that are chatty with each other, as this will improve their efficiency significantly. Using a multi-tenant JVM is one good option.
https://www.youtube.com/watch?v=RH8DsP1CkpY
JVM Memory Leaks (Page last updated September 2021, Added 2021-10-29, Author Mikhail Horbunov, Publisher Engineering Community). Tips:
- You get a memory leak when you are referencing objects which your application no longer uses but continues to (accidentally) reference those objects.
- The most common memory leaks are from: globally retained collections (eg caches, static fields, shared buffers); equals-hashcode mismatch bugs (incorrect implementations, mutable keys); forgetting to close resources; no longer needed references to outer classes from still used inner classes & lambdas/closures; and adding objects to threadlocals on reused threads (eg in thread pools), but not removing them when they are no longer used.
- Symptoms of memory leaks are: OutOfMemoryErrors; crashes with code 137; performance degradation and frequent GC pauses.
- Unmanaged and off heap memory will be referenced from somewhere in the heap, but could be held alive by a small object hard to find in the heap so the cause of these type of memory leaks can be quite hard to identify.
- Analysis of memory leaks: Heap dumps can be analyzed using various heap dump analyzers; GC output can be analyzed with GC log analyzers; and JMX and profilers can give let you analyze in-memory data.
- Ways to avoid memory leaks: avoid global collections; ensure equals/hashcode are correctly implemented and use immutable objects as keys in maps; use try-with-resources; prefer static inner classes (as opposed to other types of inner classes); remove objects from thread locals when they are no longer needed.
https://www.youtube.com/watch?v=w1fdOksedBg
Java performance talk - Performance Engineers Clubhouse (Page last updated August 2021, Added 2021-10-29, Author Ram Lakahmanan, Publisher yCrash). Tips:
- The JVM process size is the heap used plus native memory used (metaspace, thread stacks, and other off heap regions) .
- The typical JVM application saturates the memory of the system before other resources (CPU/storage/network). This means if you make your Java code memory efficient, you can reduce the limiting costs of your deployments.
- Memory is wasted typically from: duplicate strings; inefficient object arrays; duplicate primitive arrays; inefficient collections (resized, sized wrong); duplicate objects; objects waiting finalization.
Jack Shirazi
Back to newsletter 251 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/newtips251.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us