Download presentation
Presentation is loading. Please wait.
Published byJeffery Barrett Modified over 6 years ago
1
Runtime Analysis of Hotspot Java Virtual Machine
Progress Report Meeting December 7, 2017 Houssem Daoud Michel Dagenais École Polytechnique de Montréal Laboratoire DORSAL
2
Agenda Introduction Thread Management JIT compilation
Object Allocation Garbage Collection Java Flame Chart Conclusion POLYTECHNIQUE MONTREAL – Houssem Daoud
3
Introduction Features of Java: Object Oriented Platform independent
Dynamic Interpreted/Compiled Hotspot is an open source virtual machine by Oracle POLYTECHNIQUE MONTREAL – Houssem Daoud
4
Introduction Runtime Environment Source .java Class Loader Compiler
Java Interpreter JIT Compiler Bytecode .class Execution Engine Operating System Hardware POLYTECHNIQUE MONTREAL – Houssem Daoud
5
Introduction Hotspot VM provides:
Class loader Java bytecode interpreter JIT compiler Automatic memory management mechanisms Several garbage collectors The behavior of programs is sometimes unpredictable. Runtime analysis is required POLYTECHNIQUE MONTREAL – Houssem Daoud
6
Introduction Most available tools use userspace tracing or JMX technology to collect runtime information. Some important events are not visible from the userspace POLYTECHNIQUE MONTREAL – Houssem Daoud
7
Introduction Kernel tracing provides more information about the system: System calls, disk access, network access, interrupts, etc. But.. POLYTECHNIQUE MONTREAL – Houssem Daoud
8
Our goal is Introduction
To provide a JVM analysis tool that bridges the gap between userspace and kernel space traces POLYTECHNIQUE MONTREAL – Houssem Daoud
9
Agenda Introduction Thread Management JIT compilation
Object Allocation Garbage Collection Java Flame Chart Conclusion POLYTECHNIQUE MONTREAL – Houssem Daoud
10
Thread Management Hotspot VM uses a 1:1 threading model
Each Java thread (JavaThread) is mapped to a native operating system thread (OSThread) The main types of threads are: Compiler threads, GC threads, VM ops threads, etc.. JIT Compiler Garbage collector JIT 1 JIT 2 GC 1 GC 2 Main thread GC 4 GC 3 Reference handler Finalizer Signal Dispatcher POLYTECHNIQUE MONTREAL – Houssem Daoud A simple java program can generate a dozen or more threads in the system
11
Thread Management (name, java_threadid, os_threadid, deamon)
thread_start thread_stop thread_sleep_start thread_sleep_end (name, java_threadid, os_threadid, deamon) We use this information to associate Java thread to Kernel threads POLYTECHNIQUE MONTREAL – Houssem Daoud
12
Thread Management Unified Kernel/User-space view for Java threads
POLYTECHNIQUE MONTREAL – Houssem Daoud
13
Thread Management We can see low-level details
syscall_entry_futex Java threads can be considered RUNNING from the user-space point of view, but in reality they are interrupted by the operating system. POLYTECHNIQUE MONTREAL – Houssem Daoud
14
Agenda Introduction Thread Management JIT compilation
Object Allocation Garbage Collection Java Flame Chart Conclusion POLYTECHNIQUE MONTREAL – Houssem Daoud
15
JIT Compilation Hotspot VM is equipped with an advanced just-in-time (JIT) compiler C1 provides fast compilation. C2 is more aggressive and generates more optimized code Tiered compilation: Methods are first compiled by C1; as they become hot, they are recompiled by C2. POLYTECHNIQUE MONTREAL – Houssem Daoud
16
JIT Compilation We added the following tracepoints: method_compile_begin, method_compile_end and method_load POLYTECHNIQUE MONTREAL – Houssem Daoud
17
JIT Compilation The view shows that there is one C1 thread and three C2 threads. We can see the methods that are currently being compiled. POLYTECHNIQUE MONTREAL – Houssem Daoud
18
Agenda Introduction Thread Management JIT Compilation
Object Allocation Garbage Collection Java Flame Chart Conclusion POLYTECHNIQUE MONTREAL – Houssem Daoud
19
Object Allocation Each Java thread has its own TLAB (Thread Local Allocation Buffer). Allocating an object inside TLAB doesn't require synchronization mechanisms. Java objects are preferably allocated inside TLABs. Large objects are allocated outside We instrumented the memory management subsystem to track object allocation: alloc_new_tlab and alloc_outside_tlab POLYTECHNIQUE MONTREAL – Houssem Daoud
20
Object Allocation POLYTECHNIQUE MONTREAL – Houssem Daoud
21
Agenda Introduction Thread Management JIT compilation
Object Allocation Garbage Collection Java Flame Chart Conclusion POLYTECHNIQUE MONTREAL – Houssem Daoud
22
Garbage Collection The garbage collector reclaims unused memory by automatically removing unreachable objects Characteristics of garbage collectors Serial / Parallel Concurrent / Stop-the-world Compacting / Non-Compacting Young generation Promotion Old generation POLYTECHNIQUE MONTREAL – Houssem Daoud
23
Garbage Collection report_gc_start and report_gc_end provide information about the garbage collection (start, end, major/minor, type) alloc_requiring_gc indicates the thread that caused the garbage collection POLYTECHNIQUE MONTREAL – Houssem Daoud
24
Garbage Collection By adding the userspace callstack context to garbage collector events, it is possible know the reason and the type of triggered GCs POLYTECHNIQUE MONTREAL – Houssem Daoud
25
Agenda Introduction Thread Management JIT compilation
Object Allocation Garbage Collection Java Flame Chart Conclusion POLYTECHNIQUE MONTREAL – Houssem Daoud
26
Java Flame Chart We are able to get the flame chart of a java program by instrumenting methods entry/exit (high frequency event) POLYTECHNIQUE MONTREAL – Houssem Daoud
27
Conclusion We instrumented Hotspot JVM
We used Kernel/User-space traces to provide an advanced performance analysis tool for Java applications The analysis covers JIT compilation, object allocation, garbage collection and method invocation. POLYTECHNIQUE MONTREAL – Houssem Daoud
28
Thank You ! POLYTECHNIQUE MONTREAL – Houssem Daoud
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.