SlideShare a Scribd company logo
Why GC is eating all my CPU? 
Aprof - Java Memory Allocation Profiler 
Roman Elizarov, Devexperts 
Joker Conference, St. Petersburg, 2014
Java Memory Allocation Profiler 
Why it is needed? 
When to use it? 
How it works? 
How to use it? 
DISCLAIMER Herein lots of: 
omissions, 
simplifications, 
half-truths, 
intentionally misleading information. [Almost] all the truth is at the end of presentation!
Java 
•Does not have stack-allocation, does not have structs, does not have tuples… 
•Promotes the “Object Oriented” style of programming with lots of object allocations 
–Most of which are only temporary → garbage
Garbage collection
Enjoy Java and GC 
Until it becomes performance bottleneck
http://odetocode.com/Blogs/scott/archive/2008/07/15/optimizing-linq-queries.aspx
So, measure GC! 
http://clearlypresentable.files.wordpress.com/2010/10/manage-measure.jpg
Use simple tools…
… or use advanced tools …
…or use the logs and APIs 
•Always use the following settings in prod: -XX:+PrintGCDetails -XX:+PrintGCTimeStamps 
– So, you can always figure out % time spent in GC by looking at your stdout as last resort. 
•To figure it out programmatically, see java.lang.management.GarbageCollectorMXBean 
Shameless commercial plug: That is how our MARS monitoring product does it
How much is much? 
•10%+ time in GC – you start worrying 
•30%+ time in GC – you do something about it 
http://upload.wikimedia.org/wikipedia/commons/4/4f/Scheibenbremse-magura.jpg
C/C++ 
Java 
Use CPU Profiler 
Find hot spots 
Fix 
Use CPU Profiler 
Find hot spots 
Wait! Allocation is FAST! (does not consume CPU) 
Troubleshooting
Object Allocation 
Garbage Collection 
Causes 
C/C++ 
Java 
Object Allocation 
CPU consumption 
Causes 
malloc/free cost
Memory allocation profiling 
•“-Xaprof” option in old JVM (<= 1.6) 
–Prints something like this on process termination: 
Allocation profile (sizes in bytes, cutoff = 0 bytes): 
___________Size__Instances__Average__Class________________ 
555807584 34737974 16 java.lang.Integer 
321112 5844 55 [I 
106104 644 165 [C 
37144 63 590 [B 
13744 325 42 [Ljava.lang.Object; 
… <the rest> 
Top alloc’d 
That is where aprof project got its name from
Where memory is allocated?
Where memory is allocated? (1) 
•Java 
–new CName(…) 
–new <prim>[…] 
–new CName[...] 
–new CName[…][…]…[…] 
•Bytecode 
–new 
–newarray 
–anewarray 
–multianewarray 
Fundamental ways to allocate memory 
Quiz for audience: What else? 
Allocate memory 
Since Java 1.0
Where memory is allocated? (2) 
–Integer i = 1234; 
–Integer i = Integer.valueOf(1234); 
Boxing – syntactic sugar to allocate memory 
Quiz for audience: What else? 
Since Java 5 
“Enhanced for loop” also desugars to method calls
Where memory is allocated? (3) 
•java.lang.Object.clone 
–Yet another true way of object allocation 
•Reflection & deserialization 
–Gets compiled into bytecode after a few invokes 
but Array.newInstance needs separate care 
•sun.misc.Unsafe.allocateInstance 
–Could be tracked, but is not in current aprof 
•JNI 
–Can be tracked via native JVMTI 
aprof is a pure Java tool now, does not track it 
Quiz for audience: What else?
Where memory is allocated? (4) 
Captured 
In new lambda 
Since Java 8 
Capturing Java 8 Lambda Closure
Let’s instrument bytecodes 
java –javaagent:aprof.jar … 
JVM API to write bytecode instrumenting agents in Java
Define Premain-Class 
Premain-Class: com.devexperts.aprof.AProfAgent Boot-Class-Path: aprof.jar Can-Redefine-Classes: true 
aprof.jar!META-INF/MANIFEST.MF
Install transformer 
That is what we need! 
Ah… The secret sauce!
Manipulate bytecode with ASM 
•ObjectWeb ASM is an open source lib to help 
–Easy to use for bytecode manipulation 
–Extremely fast (suited to on-the-fly manipulation) 
ClassReader 
ClassVisitor 
ClassWriter 
MethodVisitor
Instrument around bytecodes
Generate calls to profiling methods 
New array bytecode 
Needs length to compute object size 
Index of location 
invoke static profiling method
Generate calls to profiling methods 
Regular new object bytecode 
Needs class to compute object size
Example transformation 
public int[] newArray(int); 
Code: 
0: iload_1 
1: newarray int 
3: areturn 
public int[] newArray(int); Code: 0: iload_1 1: dup 2: sipush 4137 5: invokestatic #31 8: newarray int 10: areturn 
java –javaagent:aprof.jar=dump.classes.dir=dump … 
Method com/devexperts/aprof/AProfOps. intAllocateArraySize 
Assigned index 
return new int[n];
We cannot measure the system without affecting it 
Need to minimize measurement effect 
Measure garbage without producing garbage (do not allocate memory)
Garbage-free code? 
[ ] Class-transformation 
Only during load (don’t care) 
[ ] Object-class size computation 
Only once per class (don’t care) 
[x] Count individual allocations 
It has to be garbage-free 
and it is (once all allocation locations were visited)
Count all allocations 
Uses array access, because index enumerates (location, type) pairs consecutively
Compute object size 
Array size 
… very fast computation
Compute object size 
Regular object size 
… and cache the size for class 
Precise and actual size (!)
Let’s try it 
http://3.bp.blogspot.com/-vUgjzK5P-kQ/ToYOTLjqBTI/AAAAAAAAFu0/2ZGrGV9y0c4/s640/tumblr_komtamvGna1qzvjtno1_500.jpg
Big business app 
Top allocated data types with locations 
------------------------------------------------------------- 
char[]: 330,657,880 bytes in 5,072,613 objects 
java.util.Arrays.copyOfRange: 131,299,568 bytes in … 
aprof.txt 
Oops! That is not informative 
We knew that it will produce a lot of char[] garbage in strings! 
aprof agent
Need allocation context 
Call stack: 
•MyDataClass.getData(int) 
•java.lang.StringBuilder.toString() 
•Java.lang.String.String(char[], int, int) 
•Java.util.Arrays.copyOfRange(char[], int, int[]) 
•new char[] 
But it is allocated here 
We want this location
Aprof Tracked Methods 
java –jar aprof.jar export details.config 
… 
java.lang.StringBuilder 
<init> 
append 
appendCodePoint 
ensureCapacity 
insert 
setLength 
subSequence 
substring 
trimToSize 
toString 
… 
details.config 
Java RT methods that might allocate memory
How it is done? 
•Tracked via thread-local instance of class com.devexperts.aprof.LocationStack 
•Local variable is injected into 
–methods that allocate memory 
–methods that invoke tracked methods 
–tracked methods themselves 
•Local variable is initialized on first use
public int[] newArray(int); 
Code: 
0: aconst_null 
1: astore_2 
2: iload_1 
3: dup 
4: aload_2 
5: dup 
6: ifnonnull 15 
9: pop 
10: invokestatic #25 
13: dup 
14: astore_2 
15: sipush 4137 
18: invokestatic #31 
21: newarray int 
23: areturn 
Example transformation (actual) 
LocationStack stack = null; // local var 
If (stack == null) 
stack = LocationStack.get(); 
return new int[n];
Looks scary 
… But fast in practice 
–Long-running methods retrieve LocationStack from ThreadLocal only once 
–HotSpot optimizes this ugly code quite well 
–It only affects code that does memory allocations or uses tracked (memory allocating!) methods 
–Does not allocate memory during stable operation 
It has no performance impact on dense garbage-free computation code, various getters, etc
Big business app 
Top allocated data types with reverse location traces 
----------------------------------------------------- 
char[]: 330,657,880 bytes in 5,072,613 objects 
java.util.Arrays.copyOfRange: 131,299,568 bytes in … 
java.lang.StringBuilder.toString: … 
MyBusinessMethod: … 
… (more!) 
aprof.txt 
aprof agent 
Got you!
Actual call stack: … 
•MyBusinessMethod 
•java.lang.StringBuilder.toString() 
•Java.lang.String.String(char[], int, int) 
•Java.util.Arrays.copyOfRange(char[], int, int[]) 
•new char[] 
Aprof dump vs actual call stack 
Top allocated data types with reverse location traces ----------------------------------------------------- char[]: 330,657,880 bytes in 5,072,613 objects java.util.Arrays.copyOfRange: 131,299,568 bytes in … java.lang.StringBuilder.toString: … MyBusinessMethod: … … (more!) 
At most 4 items are displayed in aprof dump 
(1) Type that was allocated 
(2) Where it was allocated 
(1) 
(2) 
(3) Outermost tracked method 
(4) Caller of the outermost tracked method 
(3) 
(4)
But what if 
… caught MyFrameworkMethod allocating memory instead? 
Add it to tracked methods list 
java –javaagent:aprof.jar=track=MyFrameworkMethod … 
java –javaagent:aprof.jar=track.file=details.config … 
a) 
b) 
Repeat
Poor man’s catch-all 
java –javaagent:aprof.jar=+unknown … 
Injects the profiling code right into java.lang.Object constructor 
•Does some mental accounting to exclude allocation that were already counted, reports the difference 
•The difference can appear from JNI object allocations. But location is unknown anyway. 
•Does not help with tracking JNI array allocations at all (no constructor invocation)
Top allocated data types with reverse location traces 
----------------------------------------------------- 
java.util.ArrayList$Itr: 32,000,006,272 bytes … 
java.util.ArrayList.iterator: 32,000,006,272 bytes … IterateALot.sumList: 32,000,000,000 bytes … 
Iterator is allocated here
java -XX:+PrintGCDetails -XX:+PrintGCTimeStamps … 
Shouldn’t GC work like hell? 
[PSYoungGen: 512K->400K(1024K)] 512K->408K(126464K) 
[PSYoungGen: 912K->288K(1024K)] 920K->296K(126464K) 
[PSYoungGen: 800K->352K(1024K)] 808K->360K(126464K) 
[PSYoungGen: 864K->336K(1536K)] 872K->344K(126976K) 
[PSYoungGen: 1360K->352K(1536K)] 1368K->360K(126976K) 
[PSYoungGen: 1376K->352K(2560K)] 1384K->360K(128000K) 
[PSYoungGen: 2400K->0K(2560K)] 2408K->284K(128000K) 
[PSYoungGen: 2048K->0K(4608K)] 2332K->284K(130048K) 
And that is it! No more GC! 
What is going on here?
HotSpot allocation elimination 
Deep inlining 
Escape analysis 
Allocation elimination
Aprof allocation elimination checking 
java –javaagent:aprof.jar:+check.eliminate.allocation -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation … 
Top allocated data types with reverse location traces 
----------------------------------------------------- 
java.util.ArrayList$Itr: 32,000,006,272 bytes … 
java.util.ArrayList.iterator: 32,000,006,272 bytes … IterateALot.sumList: … ; possibly eliminated 
1.HotSpot writes hs_xxx.log files 
2.Aprof parses them to learn eliminated allocation locations
Some additional options/features 
•histogram – track array allocation separately for different size brackets 
•file – configure dump file, use #### in file name to auto-number files 
•file.append – append dump to file every, instead of overwriting 
•time – time period to write dumps, 
defaults to a minute 
java –jar aprof.jar 
To get help
Advanced topics (1) 
•Transforming classes that were already loaded 
–… before aprof Pre-Main had even got control 
•Profiling the profiler 
–aprof records and reports its own allocations 
•Caching class meta-info for each class-loader 
–for fast class transformation 
•Aggregating classes with dynamic names like “sun.reflect.GeneratedConstructorAccessorX” 
–to avoid memory leaks (out of memory)
Advanced topics (2) 
•Handling HotSpot intrinsics 
–Arrays.copyOf and Arrays.copyOfRange do not actually run their bytecode in HotSpot (intrinsic) 
aprof has to treat them as first-class allocations 
•Avoiding class-name clashes with target app 
–asm and aprof transformer are actually loaded from a separate inner class loader 
•Accessing index of counters via fast hash 
–http://elizarov.livejournal.com/tag/hash 
•Writing big reports without tons of garbage
The source 
https://github.com/devexperts/aprof 
GPL 3.0 
Your contributions are welcome
Known issues 
•Lambda capture memory allocations are not tracked nor reported in any way 
–Need to track metafactory calls and unnamed classes it generates 
•Java 8 library methods (collections, streams, etc) are not included into default list of tracked methods 
–Need to work through them and include them 
•JNI allocations are not properly tracked 
–Need to write native JVMTI agent to track them 
Where you can help 
Mostly done in aprof v30 
To get actual code location
Questions? 
Feedback? 
aprof@devexperts.com 
elizarov@devexperts.com

More Related Content

What's hot

Spark + Parquet In Depth: Spark Summit East Talk by Emily Curtin and Robbie S...
Spark + Parquet In Depth: Spark Summit East Talk by Emily Curtin and Robbie S...Spark + Parquet In Depth: Spark Summit East Talk by Emily Curtin and Robbie S...
Spark + Parquet In Depth: Spark Summit East Talk by Emily Curtin and Robbie S...
Spark Summit
 
Cassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series ModelingCassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series Modeling
Vassilis Bekiaris
 
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin HuaiA Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
Databricks
 
Serverless Framework (2018)
Serverless Framework (2018)Serverless Framework (2018)
Serverless Framework (2018)
Rowell Belen
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
Talha Ocakçı
 
Optimizing Performance in Rust for Low-Latency Database Drivers
Optimizing Performance in Rust for Low-Latency Database DriversOptimizing Performance in Rust for Low-Latency Database Drivers
Optimizing Performance in Rust for Low-Latency Database Drivers
ScyllaDB
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into Cassandra
Jim Hatcher
 
Hive and Apache Tez: Benchmarked at Yahoo! Scale
Hive and Apache Tez: Benchmarked at Yahoo! ScaleHive and Apache Tez: Benchmarked at Yahoo! Scale
Hive and Apache Tez: Benchmarked at Yahoo! ScaleDataWorks Summit
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
Jonas Bonér
 
MongoDB For C++ Developers
MongoDB For C++ DevelopersMongoDB For C++ Developers
MongoDB For C++ Developers
Ynon Perek
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesThreading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Lauren Yew
 
Whoops, The Numbers Are Wrong! Scaling Data Quality @ Netflix
Whoops, The Numbers Are Wrong! Scaling Data Quality @ NetflixWhoops, The Numbers Are Wrong! Scaling Data Quality @ Netflix
Whoops, The Numbers Are Wrong! Scaling Data Quality @ Netflix
DataWorks Summit
 
Apache Spark Core—Deep Dive—Proper Optimization
Apache Spark Core—Deep Dive—Proper OptimizationApache Spark Core—Deep Dive—Proper Optimization
Apache Spark Core—Deep Dive—Proper Optimization
Databricks
 
SEED - Halcyon Architecture
SEED - Halcyon ArchitectureSEED - Halcyon Architecture
SEED - Halcyon Architecture
Electronic Arts / DICE
 
Write Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdfWrite Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdf
Eric Xiao
 
Apache Spark At Scale in the Cloud
Apache Spark At Scale in the CloudApache Spark At Scale in the Cloud
Apache Spark At Scale in the Cloud
Databricks
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact version
scalaconfjp
 
Netflix Global Cloud Architecture
Netflix Global Cloud ArchitectureNetflix Global Cloud Architecture
Netflix Global Cloud Architecture
Adrian Cockcroft
 
(DAT401) Amazon DynamoDB Deep Dive
(DAT401) Amazon DynamoDB Deep Dive(DAT401) Amazon DynamoDB Deep Dive
(DAT401) Amazon DynamoDB Deep Dive
Amazon Web Services
 
Frame - Feature Management for Productive Machine Learning
Frame - Feature Management for Productive Machine LearningFrame - Feature Management for Productive Machine Learning
Frame - Feature Management for Productive Machine Learning
David Stein
 

What's hot (20)

Spark + Parquet In Depth: Spark Summit East Talk by Emily Curtin and Robbie S...
Spark + Parquet In Depth: Spark Summit East Talk by Emily Curtin and Robbie S...Spark + Parquet In Depth: Spark Summit East Talk by Emily Curtin and Robbie S...
Spark + Parquet In Depth: Spark Summit East Talk by Emily Curtin and Robbie S...
 
Cassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series ModelingCassandra Basics, Counters and Time Series Modeling
Cassandra Basics, Counters and Time Series Modeling
 
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin HuaiA Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
A Deep Dive into Spark SQL's Catalyst Optimizer with Yin Huai
 
Serverless Framework (2018)
Serverless Framework (2018)Serverless Framework (2018)
Serverless Framework (2018)
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Optimizing Performance in Rust for Low-Latency Database Drivers
Optimizing Performance in Rust for Low-Latency Database DriversOptimizing Performance in Rust for Low-Latency Database Drivers
Optimizing Performance in Rust for Low-Latency Database Drivers
 
Using Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into CassandraUsing Spark to Load Oracle Data into Cassandra
Using Spark to Load Oracle Data into Cassandra
 
Hive and Apache Tez: Benchmarked at Yahoo! Scale
Hive and Apache Tez: Benchmarked at Yahoo! ScaleHive and Apache Tez: Benchmarked at Yahoo! Scale
Hive and Apache Tez: Benchmarked at Yahoo! Scale
 
Scalability, Availability & Stability Patterns
Scalability, Availability & Stability PatternsScalability, Availability & Stability Patterns
Scalability, Availability & Stability Patterns
 
MongoDB For C++ Developers
MongoDB For C++ DevelopersMongoDB For C++ Developers
MongoDB For C++ Developers
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesThreading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
 
Whoops, The Numbers Are Wrong! Scaling Data Quality @ Netflix
Whoops, The Numbers Are Wrong! Scaling Data Quality @ NetflixWhoops, The Numbers Are Wrong! Scaling Data Quality @ Netflix
Whoops, The Numbers Are Wrong! Scaling Data Quality @ Netflix
 
Apache Spark Core—Deep Dive—Proper Optimization
Apache Spark Core—Deep Dive—Proper OptimizationApache Spark Core—Deep Dive—Proper Optimization
Apache Spark Core—Deep Dive—Proper Optimization
 
SEED - Halcyon Architecture
SEED - Halcyon ArchitectureSEED - Halcyon Architecture
SEED - Halcyon Architecture
 
Write Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdfWrite Faster SQL with Trino.pdf
Write Faster SQL with Trino.pdf
 
Apache Spark At Scale in the Cloud
Apache Spark At Scale in the CloudApache Spark At Scale in the Cloud
Apache Spark At Scale in the Cloud
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact version
 
Netflix Global Cloud Architecture
Netflix Global Cloud ArchitectureNetflix Global Cloud Architecture
Netflix Global Cloud Architecture
 
(DAT401) Amazon DynamoDB Deep Dive
(DAT401) Amazon DynamoDB Deep Dive(DAT401) Amazon DynamoDB Deep Dive
(DAT401) Amazon DynamoDB Deep Dive
 
Frame - Feature Management for Productive Machine Learning
Frame - Feature Management for Productive Machine LearningFrame - Feature Management for Productive Machine Learning
Frame - Feature Management for Productive Machine Learning
 

Similar to Why GC is eating all my CPU?

DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
Roman Elizarov
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
Luiz Fernando Teston
 
java training faridabad
java training faridabadjava training faridabad
java training faridabad
Woxa Technologies
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
Sylvain Wallez
 
Java Tutorials
Java Tutorials Java Tutorials
Java Tutorials
Woxa Technologies
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
Sylvain Wallez
 
Compromising Linux Virtual Machines with Debugging Mechanisms
Compromising Linux Virtual Machines with Debugging MechanismsCompromising Linux Virtual Machines with Debugging Mechanisms
Compromising Linux Virtual Machines with Debugging Mechanisms
Russell Sanford
 
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
chen yuki
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
Richard Leland
 
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Universitat Politècnica de Catalunya
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profiler
Ihor Bobak
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
National Cheng Kung University
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
Alexandre Rafalovitch
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Lucidworks
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
PROIDEA
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
flyinweb
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
LovelitJose
 
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementQuantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
Emery Berger
 
Deep Learning in Spark with BigDL by Petar Zecevic at Big Data Spain 2017
Deep Learning in Spark with BigDL by Petar Zecevic at Big Data Spain 2017Deep Learning in Spark with BigDL by Petar Zecevic at Big Data Spain 2017
Deep Learning in Spark with BigDL by Petar Zecevic at Big Data Spain 2017
Big Data Spain
 

Similar to Why GC is eating all my CPU? (20)

DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
java training faridabad
java training faridabadjava training faridabad
java training faridabad
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
Java Tutorials
Java Tutorials Java Tutorials
Java Tutorials
 
Inside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUGInside the JVM - Follow the white rabbit! / Breizh JUG
Inside the JVM - Follow the white rabbit! / Breizh JUG
 
Compromising Linux Virtual Machines with Debugging Mechanisms
Compromising Linux Virtual Machines with Debugging MechanismsCompromising Linux Virtual Machines with Debugging Mechanisms
Compromising Linux Virtual Machines with Debugging Mechanisms
 
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities o...
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
 
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
 
Core java msc
Core java mscCore java msc
Core java msc
 
Hadoop cluster performance profiler
Hadoop cluster performance profilerHadoop cluster performance profiler
Hadoop cluster performance profiler
 
Understanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual MachineUnderstanding the Dalvik Virtual Machine
Understanding the Dalvik Virtual Machine
 
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approachSolr Troubleshooting - TreeMap approach
Solr Troubleshooting - TreeMap approach
 
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
 
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak   CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
CONFidence 2015: DTrace + OSX = Fun - Andrzej Dyjak
 
Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨Nodejs性能分析优化和分布式设计探讨
Nodejs性能分析优化和分布式设计探讨
 
Programming in java basics
Programming in java  basicsProgramming in java  basics
Programming in java basics
 
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementQuantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
 
Deep Learning in Spark with BigDL by Petar Zecevic at Big Data Spain 2017
Deep Learning in Spark with BigDL by Petar Zecevic at Big Data Spain 2017Deep Learning in Spark with BigDL by Petar Zecevic at Big Data Spain 2017
Deep Learning in Spark with BigDL by Petar Zecevic at Big Data Spain 2017
 

More from Roman Elizarov

Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018
Roman Elizarov
 
Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017
Roman Elizarov
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017
Roman Elizarov
 
Fresh Async with Kotlin @ QConSF 2017
Fresh Async with Kotlin @ QConSF 2017Fresh Async with Kotlin @ QConSF 2017
Fresh Async with Kotlin @ QConSF 2017
Roman Elizarov
 
Scale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOneScale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOne
Roman Elizarov
 
Kotlin Coroutines Reloaded
Kotlin Coroutines ReloadedKotlin Coroutines Reloaded
Kotlin Coroutines Reloaded
Roman Elizarov
 
Lock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin CoroutinesLock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin Coroutines
Roman Elizarov
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutines
Roman Elizarov
 
Non blocking programming and waiting
Non blocking programming and waitingNon blocking programming and waiting
Non blocking programming and waiting
Roman Elizarov
 
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
Roman Elizarov
 
Многопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и ПрактикаМногопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и Практика
Roman Elizarov
 
Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Wait for your fortune without Blocking!
Wait for your fortune without Blocking!
Roman Elizarov
 
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
Roman Elizarov
 
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
Roman Elizarov
 
Многопоточные Алгоритмы (для BitByte 2014)
Многопоточные Алгоритмы (для BitByte 2014)Многопоточные Алгоритмы (для BitByte 2014)
Многопоточные Алгоритмы (для BitByte 2014)Roman Elizarov
 
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)Roman Elizarov
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and FallaciesRoman Elizarov
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure javaRoman Elizarov
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 

More from Roman Elizarov (20)

Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018
 
Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017
 
Fresh Async with Kotlin @ QConSF 2017
Fresh Async with Kotlin @ QConSF 2017Fresh Async with Kotlin @ QConSF 2017
Fresh Async with Kotlin @ QConSF 2017
 
Scale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOneScale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOne
 
Kotlin Coroutines Reloaded
Kotlin Coroutines ReloadedKotlin Coroutines Reloaded
Kotlin Coroutines Reloaded
 
Lock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin CoroutinesLock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin Coroutines
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutines
 
Non blocking programming and waiting
Non blocking programming and waitingNon blocking programming and waiting
Non blocking programming and waiting
 
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
 
Многопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и ПрактикаМногопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и Практика
 
Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Wait for your fortune without Blocking!
Wait for your fortune without Blocking!
 
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
 
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
 
Многопоточные Алгоритмы (для BitByte 2014)
Многопоточные Алгоритмы (для BitByte 2014)Многопоточные Алгоритмы (для BitByte 2014)
Многопоточные Алгоритмы (для BitByte 2014)
 
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and Fallacies
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure java
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
 

Recently uploaded

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
Globus
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
Tier1 app
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Jay Das
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
informapgpstrackings
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
Ortus Solutions, Corp
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 

Recently uploaded (20)

GlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote sessionGlobusWorld 2024 Opening Keynote session
GlobusWorld 2024 Opening Keynote session
 
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERRORTROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
TROUBLESHOOTING 9 TYPES OF OUTOFMEMORYERROR
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdfEnhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
Enhancing Project Management Efficiency_ Leveraging AI Tools like ChatGPT.pdf
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 

Why GC is eating all my CPU?

  • 1. Why GC is eating all my CPU? Aprof - Java Memory Allocation Profiler Roman Elizarov, Devexperts Joker Conference, St. Petersburg, 2014
  • 2. Java Memory Allocation Profiler Why it is needed? When to use it? How it works? How to use it? DISCLAIMER Herein lots of: omissions, simplifications, half-truths, intentionally misleading information. [Almost] all the truth is at the end of presentation!
  • 3. Java •Does not have stack-allocation, does not have structs, does not have tuples… •Promotes the “Object Oriented” style of programming with lots of object allocations –Most of which are only temporary → garbage
  • 5. Enjoy Java and GC Until it becomes performance bottleneck
  • 7. So, measure GC! http://clearlypresentable.files.wordpress.com/2010/10/manage-measure.jpg
  • 9. … or use advanced tools …
  • 10. …or use the logs and APIs •Always use the following settings in prod: -XX:+PrintGCDetails -XX:+PrintGCTimeStamps – So, you can always figure out % time spent in GC by looking at your stdout as last resort. •To figure it out programmatically, see java.lang.management.GarbageCollectorMXBean Shameless commercial plug: That is how our MARS monitoring product does it
  • 11. How much is much? •10%+ time in GC – you start worrying •30%+ time in GC – you do something about it http://upload.wikimedia.org/wikipedia/commons/4/4f/Scheibenbremse-magura.jpg
  • 12.
  • 13. C/C++ Java Use CPU Profiler Find hot spots Fix Use CPU Profiler Find hot spots Wait! Allocation is FAST! (does not consume CPU) Troubleshooting
  • 14. Object Allocation Garbage Collection Causes C/C++ Java Object Allocation CPU consumption Causes malloc/free cost
  • 15. Memory allocation profiling •“-Xaprof” option in old JVM (<= 1.6) –Prints something like this on process termination: Allocation profile (sizes in bytes, cutoff = 0 bytes): ___________Size__Instances__Average__Class________________ 555807584 34737974 16 java.lang.Integer 321112 5844 55 [I 106104 644 165 [C 37144 63 590 [B 13744 325 42 [Ljava.lang.Object; … <the rest> Top alloc’d That is where aprof project got its name from
  • 16. Where memory is allocated?
  • 17. Where memory is allocated? (1) •Java –new CName(…) –new <prim>[…] –new CName[...] –new CName[…][…]…[…] •Bytecode –new –newarray –anewarray –multianewarray Fundamental ways to allocate memory Quiz for audience: What else? Allocate memory Since Java 1.0
  • 18. Where memory is allocated? (2) –Integer i = 1234; –Integer i = Integer.valueOf(1234); Boxing – syntactic sugar to allocate memory Quiz for audience: What else? Since Java 5 “Enhanced for loop” also desugars to method calls
  • 19. Where memory is allocated? (3) •java.lang.Object.clone –Yet another true way of object allocation •Reflection & deserialization –Gets compiled into bytecode after a few invokes but Array.newInstance needs separate care •sun.misc.Unsafe.allocateInstance –Could be tracked, but is not in current aprof •JNI –Can be tracked via native JVMTI aprof is a pure Java tool now, does not track it Quiz for audience: What else?
  • 20. Where memory is allocated? (4) Captured In new lambda Since Java 8 Capturing Java 8 Lambda Closure
  • 21. Let’s instrument bytecodes java –javaagent:aprof.jar … JVM API to write bytecode instrumenting agents in Java
  • 22. Define Premain-Class Premain-Class: com.devexperts.aprof.AProfAgent Boot-Class-Path: aprof.jar Can-Redefine-Classes: true aprof.jar!META-INF/MANIFEST.MF
  • 23. Install transformer That is what we need! Ah… The secret sauce!
  • 24. Manipulate bytecode with ASM •ObjectWeb ASM is an open source lib to help –Easy to use for bytecode manipulation –Extremely fast (suited to on-the-fly manipulation) ClassReader ClassVisitor ClassWriter MethodVisitor
  • 26. Generate calls to profiling methods New array bytecode Needs length to compute object size Index of location invoke static profiling method
  • 27. Generate calls to profiling methods Regular new object bytecode Needs class to compute object size
  • 28. Example transformation public int[] newArray(int); Code: 0: iload_1 1: newarray int 3: areturn public int[] newArray(int); Code: 0: iload_1 1: dup 2: sipush 4137 5: invokestatic #31 8: newarray int 10: areturn java –javaagent:aprof.jar=dump.classes.dir=dump … Method com/devexperts/aprof/AProfOps. intAllocateArraySize Assigned index return new int[n];
  • 29. We cannot measure the system without affecting it Need to minimize measurement effect Measure garbage without producing garbage (do not allocate memory)
  • 30. Garbage-free code? [ ] Class-transformation Only during load (don’t care) [ ] Object-class size computation Only once per class (don’t care) [x] Count individual allocations It has to be garbage-free and it is (once all allocation locations were visited)
  • 31. Count all allocations Uses array access, because index enumerates (location, type) pairs consecutively
  • 32. Compute object size Array size … very fast computation
  • 33. Compute object size Regular object size … and cache the size for class Precise and actual size (!)
  • 34. Let’s try it http://3.bp.blogspot.com/-vUgjzK5P-kQ/ToYOTLjqBTI/AAAAAAAAFu0/2ZGrGV9y0c4/s640/tumblr_komtamvGna1qzvjtno1_500.jpg
  • 35. Big business app Top allocated data types with locations ------------------------------------------------------------- char[]: 330,657,880 bytes in 5,072,613 objects java.util.Arrays.copyOfRange: 131,299,568 bytes in … aprof.txt Oops! That is not informative We knew that it will produce a lot of char[] garbage in strings! aprof agent
  • 36. Need allocation context Call stack: •MyDataClass.getData(int) •java.lang.StringBuilder.toString() •Java.lang.String.String(char[], int, int) •Java.util.Arrays.copyOfRange(char[], int, int[]) •new char[] But it is allocated here We want this location
  • 37. Aprof Tracked Methods java –jar aprof.jar export details.config … java.lang.StringBuilder <init> append appendCodePoint ensureCapacity insert setLength subSequence substring trimToSize toString … details.config Java RT methods that might allocate memory
  • 38. How it is done? •Tracked via thread-local instance of class com.devexperts.aprof.LocationStack •Local variable is injected into –methods that allocate memory –methods that invoke tracked methods –tracked methods themselves •Local variable is initialized on first use
  • 39. public int[] newArray(int); Code: 0: aconst_null 1: astore_2 2: iload_1 3: dup 4: aload_2 5: dup 6: ifnonnull 15 9: pop 10: invokestatic #25 13: dup 14: astore_2 15: sipush 4137 18: invokestatic #31 21: newarray int 23: areturn Example transformation (actual) LocationStack stack = null; // local var If (stack == null) stack = LocationStack.get(); return new int[n];
  • 40. Looks scary … But fast in practice –Long-running methods retrieve LocationStack from ThreadLocal only once –HotSpot optimizes this ugly code quite well –It only affects code that does memory allocations or uses tracked (memory allocating!) methods –Does not allocate memory during stable operation It has no performance impact on dense garbage-free computation code, various getters, etc
  • 41. Big business app Top allocated data types with reverse location traces ----------------------------------------------------- char[]: 330,657,880 bytes in 5,072,613 objects java.util.Arrays.copyOfRange: 131,299,568 bytes in … java.lang.StringBuilder.toString: … MyBusinessMethod: … … (more!) aprof.txt aprof agent Got you!
  • 42. Actual call stack: … •MyBusinessMethod •java.lang.StringBuilder.toString() •Java.lang.String.String(char[], int, int) •Java.util.Arrays.copyOfRange(char[], int, int[]) •new char[] Aprof dump vs actual call stack Top allocated data types with reverse location traces ----------------------------------------------------- char[]: 330,657,880 bytes in 5,072,613 objects java.util.Arrays.copyOfRange: 131,299,568 bytes in … java.lang.StringBuilder.toString: … MyBusinessMethod: … … (more!) At most 4 items are displayed in aprof dump (1) Type that was allocated (2) Where it was allocated (1) (2) (3) Outermost tracked method (4) Caller of the outermost tracked method (3) (4)
  • 43. But what if … caught MyFrameworkMethod allocating memory instead? Add it to tracked methods list java –javaagent:aprof.jar=track=MyFrameworkMethod … java –javaagent:aprof.jar=track.file=details.config … a) b) Repeat
  • 44. Poor man’s catch-all java –javaagent:aprof.jar=+unknown … Injects the profiling code right into java.lang.Object constructor •Does some mental accounting to exclude allocation that were already counted, reports the difference •The difference can appear from JNI object allocations. But location is unknown anyway. •Does not help with tracking JNI array allocations at all (no constructor invocation)
  • 45.
  • 46. Top allocated data types with reverse location traces ----------------------------------------------------- java.util.ArrayList$Itr: 32,000,006,272 bytes … java.util.ArrayList.iterator: 32,000,006,272 bytes … IterateALot.sumList: 32,000,000,000 bytes … Iterator is allocated here
  • 47. java -XX:+PrintGCDetails -XX:+PrintGCTimeStamps … Shouldn’t GC work like hell? [PSYoungGen: 512K->400K(1024K)] 512K->408K(126464K) [PSYoungGen: 912K->288K(1024K)] 920K->296K(126464K) [PSYoungGen: 800K->352K(1024K)] 808K->360K(126464K) [PSYoungGen: 864K->336K(1536K)] 872K->344K(126976K) [PSYoungGen: 1360K->352K(1536K)] 1368K->360K(126976K) [PSYoungGen: 1376K->352K(2560K)] 1384K->360K(128000K) [PSYoungGen: 2400K->0K(2560K)] 2408K->284K(128000K) [PSYoungGen: 2048K->0K(4608K)] 2332K->284K(130048K) And that is it! No more GC! What is going on here?
  • 48. HotSpot allocation elimination Deep inlining Escape analysis Allocation elimination
  • 49. Aprof allocation elimination checking java –javaagent:aprof.jar:+check.eliminate.allocation -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation … Top allocated data types with reverse location traces ----------------------------------------------------- java.util.ArrayList$Itr: 32,000,006,272 bytes … java.util.ArrayList.iterator: 32,000,006,272 bytes … IterateALot.sumList: … ; possibly eliminated 1.HotSpot writes hs_xxx.log files 2.Aprof parses them to learn eliminated allocation locations
  • 50. Some additional options/features •histogram – track array allocation separately for different size brackets •file – configure dump file, use #### in file name to auto-number files •file.append – append dump to file every, instead of overwriting •time – time period to write dumps, defaults to a minute java –jar aprof.jar To get help
  • 51. Advanced topics (1) •Transforming classes that were already loaded –… before aprof Pre-Main had even got control •Profiling the profiler –aprof records and reports its own allocations •Caching class meta-info for each class-loader –for fast class transformation •Aggregating classes with dynamic names like “sun.reflect.GeneratedConstructorAccessorX” –to avoid memory leaks (out of memory)
  • 52. Advanced topics (2) •Handling HotSpot intrinsics –Arrays.copyOf and Arrays.copyOfRange do not actually run their bytecode in HotSpot (intrinsic) aprof has to treat them as first-class allocations •Avoiding class-name clashes with target app –asm and aprof transformer are actually loaded from a separate inner class loader •Accessing index of counters via fast hash –http://elizarov.livejournal.com/tag/hash •Writing big reports without tons of garbage
  • 53. The source https://github.com/devexperts/aprof GPL 3.0 Your contributions are welcome
  • 54. Known issues •Lambda capture memory allocations are not tracked nor reported in any way –Need to track metafactory calls and unnamed classes it generates •Java 8 library methods (collections, streams, etc) are not included into default list of tracked methods –Need to work through them and include them •JNI allocations are not properly tracked –Need to write native JVMTI agent to track them Where you can help Mostly done in aprof v30 To get actual code location
  • 55. Questions? Feedback? aprof@devexperts.com elizarov@devexperts.com