•
•
•
•
•
• •
•
•
•
•
•
✓
Socket s = new Socket(host, port);
InputStream in = [Link]();
while ([Link](buf) >= 0) {
// keep reading
}
Socket s = new Socket(host, port);
InputStream in = [Link]();
while ([Link](buf) >= 0) {
// keep reading
}
•
•
•
AsyncGetCallTrace(ASGCT_CallTrace *trace,
jint depth,
void* ucontext)
•
•
•
•
•
•
•
•
•
double avg(Number... numbers) {
double sum = 0;
for (Number n : numbers) {
sum += [Link]();
}
return sum / [Link];
}
x = avg(123, 45.67, 890L, 33.3f, 999, 787878L);
enum {
ticks_no_Java_frame = 0,
ticks_no_class_load = -1,
ticks_GC_active = -2,
ticks_unknown_not_Java = -3,
ticks_not_walkable_not_Java = -4,
ticks_unknown_Java = -5,
ticks_not_walkable_Java = -6,
ticks_unknown_state = -7,
ticks_thread_exit = -8,
ticks_deopt = -9,
ticks_safepoint = -10
}; src/share/vm/prims/[Link]
•
•
•
•
•
➔
• S
•
S
•
•
•
•
$ perf record –F 1009 java ...
$ perf report
$ perf record –F 1009 java ...
$ perf report
4.70% java [[Link]] [k] clear_page_c
2.10% java [Link] [.] pthread_cond_wait
1.97% java [Link] [.] Unsafe_Park
1.40% java [Link] [.] Parker::park
1.31% java [[Link]] [k] try_to_wake_up
1.31% java [Link] [.] 0x00007f8510e9e757
1.21% java [Link] [.] 0x00007f8510e9e89e
1.17% java [Link] [.] 0x00007f8510e9cc17
[Link]/jvm-profiling-tools/perf-map-agent
$ java -agentpath:/usr/lib/[Link] ...
7fe0e91175e0 140 [Link]::hashCode
7fe0e9117900 20 [Link]::min
7fe0e9117ae0 60 [Link]::length
7fe0e9117d20 180 [Link]::indexOf
SP
prev FP FP
prev FP
0
SP
•
prev FP FP
•
• prev FP
0
1. perf record
2. perf script
3. FlameGraph/[Link]
4. FlameGraph/[Link]
[Link]/brendangregg/FlameGraph
•
•
•
•
•
•
•
•
•
•
•
xfs_file_aio_read S
sys_read S
perf
system_call_fastpath
readBytes
[Link]::readBytes
[Link]::read
JavaApp::main
!
byte[] buf = new byte[bufSize];
try (FileInputStream in = new FileInputStream(fileName)) {
int bytesRead;
while ((bytesRead = [Link](buf)) > 0) {
...
} ❑
} ❑
❑
❑
❑
51
→
→
# cat /sys/devices/system/clocksource/*/available_clocksource
tsc hpet acpi_pm
# echo tsc > /sys/devices/system/clocksource/*/current_clocksource
$ cat /sys/devices/system/clocksource/clocksource0/current_clocksource
xen
•
•
•
•
•
•
•
•
•
•
•
•
•
•
synchronized (obj) {
[Link]()
LocalDateTime deadline =
[Link]().plusSeconds(10);
while ([Link]().isBefore(deadline)) {
iterations++;
}
•
•
•
→ [Link]([Link], 24);
List<String> list = new ArrayList<>();
•
•
•
$ stap -e '
probe hotspot.object_alloc { log(probestr) }
'
•
•
top
Object in Eden
top
Object in Eden
top
•
•
•
•
•
•
SampledObjectAlloc(jvmtiEnv *jvmti_env,
JNIEnv* jni_env,
jthread thread,
jobject object,
jclass object_klass,
jlong size)
SetHeapSamplingInterval(jint sampling_interval)
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•