Date post: | 15-Apr-2017 |
Category: |
Software |
Upload: | marouane-gazanayi |
View: | 1,538 times |
Download: | 1 times |
Introduction to Java Performance Tuning
Marouane Gazanayi@mgazanayi
API Dictionary
Prescriptions safety checkingPMSIRecos...
hoptimal/eVidalvidal.fr
MobileAnd much more...
WORA!
Write Once, Run Anywhere
Main concepts
javac
JVM
Main concepts
javac
scalac JVM
Main concepts
javac
JVMscalac
clojure compiler
And...
No more manual memory management
Signed: GC
SERIOUSLY
Awesome!
Generational hypothesis
Objects age
nb o
f ob
ject
s
Garbage Collector
Manages the Heap by removing "dead" objects
Garbage Collector
Garbage Collector
It is also responsible for "defragmenting" the Heap
Garbage Collector
Garbage Collector
Most employ a "stop the world" collection, meaning the running application must stop processing while the GC is engaged.
Garbage Collector
Therefore frequent or large amounts of collection affect the performance of your application.
Garbage CollectorLot of JVM options, at least always run with these
Heap
S0 S1eden
Young Generation
Survivor space
Heap
TenuredS0 S1eden
Old GenerationYoung Generation
Survivor space
Heap
Tenured Permanent
Permanent Generation
S0 S1eden
Old GenerationYoung Generation
Survivor space
Heap
Tenured Permanent
Metaspace
S0 S1eden
Old GenerationYoung Generation
Survivor space
Heap: Example
TenuredS0 S1eden
Heap: Example
11
TenuredS0 S1eden
Heap: Example
2
TenuredS0 S1eden
Heap: Example
31
TenuredS0 S1eden
Heap: Example
42
TenuredS0 S1eden
Heap: Example
3
TenuredS0 S1eden
Garbage Collector basics
SweepCompact
Copy
Garbage Collector sweep
Garbage Collector compact
Garbage Collector copy
Garbage Collector(s)
Serial GCParallel CollectorParallec CompactionConcurrent Mark Sweep CollectorG1
Garbage Collector(s)
Azul ZingShenandoah
...
HotSpot & JIT
Java source code
javac
.class file
Code cache
RuntimeHotSpot
Profiler JIT
Method cacheclass loader
java
What is performance?
The efficiency with which something reacts or
fulfills its intended purpose
What is performance?
Perceived Performance Issues
Some issues can be fixed by simply providing more information to the user
Response Time
How Long does it take for a system to react to a user's request
Throughput
How much data can be processed by the system within a given amount of time?
Load
Amount of work assigned at a given time
Utilization
Measure of how much of a system’s capacity is being consumed at a givenwork loads
Availability
Amount of time that an application is available to the end user
Technique
Estimate theoretical values and compare to measured values
Response timePoo
rAc
cept
able
Time
Load
Response timePoo
rAc
cept
able
Time
Load
ThroughputPoo
rAc
cept
able
Throughput
Load
ThroughputPoo
rAc
cept
able
Throughput
Load
ThroughputThroughput
Load
ThroughputThroughput
Load
CPU
100% CPU
CPU
100% CPU
Performance tips
A tip is a workaround for a
known problem
-Xmx == -Xms turns off adaptive sizing
Components that affect Performance
CPU
● Other processes running that are monopolizing CPU time● Single vs Parallel Processing
Input/Output
● File System ● Database ● Network Data Stores
The performance Tuning Lifecycle
1 Define Requirements
2 Measure / Test (create baseline)
3 Identify Bottleneck
4 Implements Fixes
5 Measure / Test (New Baseline)
6 Compare to Old Baseline & Requirements
7 If necessary repeat steps 3-6
The performance Tuning workflowsys cpu > 10%
user cpu
idle > 0% Memory efficient? GC
logs
system profiling: netstat, mpstat, iostat sar strace, gc logs, strace, etc...
App/CPU profilingMemory profiling, size frequency, life span,...
GC tuning, pool sizes, collectors...
Thread starvationThread dump
Application
NoneJVM
SystemYes
No
NoNo
Yes Yes
That’s all folks!