Direct Style Effect Systems -The Print[A] Example- A Comprehension Aid
Java black box profiling JUG.EKB 2016
1. Java black box profiling
Alexey Ragozin
alexey.ragozin@gmail.com
jugekb.ru 2016
2. The Problem
• There are application
• It doesn’t meat its SLA
• Users/client/stakeholders are unhappy
You are one to fix it!
3. What to do?
• Do not panic!
• Elaborate acceptance criteria
• Make sure you understand KPI and SLA
• Write out all moving parts in system
• Is problem in Java application?
Yes - You are ready to start profiling
5. Understanding targets
• Business transaction ≠ Page
• Business transaction ≠ SQL transaction
• Page ≠ HTTP request
• HTTP request ≠ SQL transaction
Make sure you know how your KPI
are translating into milliseconds
6. Just be before you start profiling
Take a deep breath
Are you sure your problem is in Java part?
Are you sure you understand target state?
Is it physically possible?
These points are trivial so it is very easy to
overlook them under stress.
Do not make that mistake!
7. Few more rule before start
Every system is a black box
Do you think that know what is inside?
You don’t!
There 3 kinds of data produced by profiling
Lies
Darn lies
Statistics
9. Do not rush!
Do not jump to profiler just yet!
Profilers employs smart techniques
to pin point specific set of bottlenecks.
Profiler’s job is to help to find you some
problem in your code,
either real or just possible!
10. Narrow problem area
What kind of problem do you have?
• 100% CPU utilization?
• 100% of all cores or just single thread 100%
• Memory problems?
• Frequent young GCs? Full GCs?
• Contention?
Identify area and employ right tool
Even if tool covers all this areas you should
understand what are you searching for?
11. Process under profiling
Stationary process
• Uniform load reasonable simulating real one
• Goal is optimizing average performance indicators
Transition process
• Goal is optimize prolonged process
• Load profile is changing over time systematically
Profiling single operation
• Goal is to optimize particular operation
12. Profiling in JVM
• JVMTI – used by almost all 3rd party profilers
• Stack trace sampling
• Byte code instrumentation
• JMX: Thread Mbeans, etc
• JVM perf counters
• GC logs
• Heap dumps / Heap histogram
• Flight recorder / mission control
13. Stack trace sampling
• Work best with stationary process
• Uniformly impacts system under test
• Do not require “calibrating”
• Result from multiple runs could be combined
• You deal with probabilities, not hard numbers
• Measure wall clock, not CPU time
14. Byte code instrumentation
• Useful for all types of experiments
• Produce some absolute numbers
Number of calls is accurate
Time is predictably skewed
• Significantlyskewperformanceofsystemundertest
• Require careful targeting
• Could measure CPU time
15. Flight recorder
• Exploit JVM internals
• Provide good context (stack traces)
• Suitable long run profiling
• Completely ignore certain aspects
• Prone to finding false problems
16. Threading MBean
Standard JVM Threading MBean
CPU usage per thread (user/sys)
Memory allocation per thread
Blocking / waiting statistics
19. Tracking down CPU hogs
1. You sampling to identify suspects
• Plain frame histogram + meditation
• Call tree + deep meditation
• Hierarchical classification
2. Instrument methods to get hard prove
• Relative number of calls between methods
3. Iterate to pin point root cause
25. Tracking contention
• Stack trace sampling
Good for “bad” contention cases
• Flight recorder
Excellent at contention analysis
• BTrace
Analyze lock access pattern using your
codebase knowledge, useful if you need gather
more application context
26. Conclusion
Understand desired target state
Progress slow and steady
• Do not get side tracked from real problem
Start from broad techniques
• Stack trace sampling
• Garbage histogram
Dig deeper with more advanced tools
• Targeted instrumentation
• Flight recorder metrics
27. KEEP
CALM
AND CRACK YOUR
JAVA PROBLEMS
Alexey Ragozin
alexey.ragozin@gmail.com
http://blog.ragozin.info
- my articles
http://github.com/aragozin
http://github.com/gridkit
- my open source code