SlideShare a Scribd company logo
1 of 46
@Work_at_Murex
•
•
• https://community.oracle.com/groups/beirut-java-user-group
•
•
•
•
•
•





Java code
Java
compiler
Bytecode
JVM
Windows Unix Mac
JVM JVM
1.



2.



•
•
•


•




•



•



•
•
int long2
Local variables
long1
Operand stack
long
objectref
•
 Finding class representation and creating runtime representation of class in the
JVM (in the method area)
 Done by a class loader, and triggered by another type referencing the class in
its run-time constant pool
•
 Bootstrap class loader (built into the JVM)
 User-defined class loaders (subclass of ClassLoader)
•
•
1. Its fully qualified name
2. Its defining class loader
•
 verifying correct structure of class representation
 creating and initializing static fields
 Resolves symbolic references from the constant pool
 Examples:
iconst_0
istore_0
aload_0  VerifyError due to wrong type
•
 Triggered upon execution of new, getstatic, putstatic, invokestatic; or
upon initialization of a subclass
 JVM synchronizes the initialization to avoid multiple threads initializing the
same class or recursive initialization.
ClassFile {
magic (4 bytes)
minor_version (2 bytes)
major_version (2 bytes)
constant_pool_count (2 bytes)
constant_pool[constant_pool_count-1] (cp_info structure)
access_flags (2 bytes)
this_class (2 bytes)
super_class (2 bytes)
interfaces_count (2 bytes)
interfaces[interfaces_count] (2 bytes)
fields_count (2 bytes)
fields[fields_count] (field_info structure)
methods_count (2 bytes)
methods[methods_count] (method_info structure)
attributes_count (2 bytes)
attributes[attributes_count] (attribute_info structure)
}
Stream of bytes stored in big-endian format, without padding or alignment
• Acts as a symbol table containing constants and symbolic references to classes,
fields and methods
• Every entry has the syntax:
• CONSTANT_Utf8, CONSTANT_Integer, CONSTANT_Float, CONSTANT_Long,
CONSTANT_Double, CONSTANT_Class, CONSTANT_String, CONSTANT_Fieldref,
CONSTANT_Methodref, CONSTANT_MethodType, CONSTANT_Package,
CONSTANT_Module, …
• Example: CONSTANT_MethodType_info
String toString(int x)
tag entry_info
(1 byte) (>= 2 bytes)
16 -> (I)Ljava/lang/String;
(tag) (index to method descriptor)
access_flags (2 bytes)
name_index (2 bytes)
descriptor_index (2 bytes)
attributes_count (2 bytes)
attributes[attributes_count] (attribute_info)
• Access flags:
ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE,
ACC_TRANSIENT, ACC_SYNTHETIC, ACC_ENUM
access_flags (2 bytes)
name_index (2 bytes)
descriptor_index (2 bytes)
attributes_count (2 bytes)
attributes[attributes_count] (attribute_info)
• Access flags:
ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED,
ACC_BRIDGE, ACC_VARARGS, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT, ACC_SYNTHETIC
•


•


objectref
invokevirtual indexbyte1 indexbyte2
Invokes an instance method based on the object reference on the operand stack
1. indexbyte1 and indexbyte2 are used to fetch method from constant pool
2. The method is looked up from the class containing the method
3. The actual method invoked depends on the actual class C of objectref (could be declared
in C, its superclass or superinterfaces)
arg2
arg1
objectref
. . .
New
frame
. . .
arg1 arg2
Local variables
invokestatic indexbyte1 indexbyte2
Invokes a static method based
 indexbyte1 and indexbyte2 are used to fetch method from constant pool
 Class or interface declaring the method is initialized if not already done
arg2
arg1
(double)
. . .
New
frame
. . . arg1 arg2
Local variables
arg1
arg1
invokespecial indexbyte1 indexbyte2
Invokes:
 private methods
 methods on superclass
 instance initialization methods (<init>)
objectref
arg2
arg1
objectref
. . .
New
frame
. . .
arg1 arg2
Local variables
invokeinterface indexbyte1 indexbyte2 count 0
Invokes interface methods
 count contains number of arguments (for historical reasons)
objectref
arg2
arg1
objectref
. . .
New
frame
. . .
arg1 arg2
Local variables
•
•
•
Interpreter
Native
execution
C1 C2
Code
cache
public void foo() {
int sum = add(8, 10);
// ...
}
public int add(int x, int y) {
return x + y;
}
-XX:InlineSmallCode=n
-XX:MaxInlineSize=35
-XX:FreqInlineSize=n
public void foo() {
int[] input = getInput();
int value = computeValue(input);
// we don’t use value
}
public int computeValue(int[] array) {
...
}
public void loopInvariantHosting(int size) {
for (int i = 0; i < 1000; i++) {
int x = 3;
int result = size * x;
// ...
}
}
public void loopInvariantHosting(int size) {
int x = 3;
int result = size * x;
for (int i = 0; i < 1000; i++) {
// ...
}
}
public void loopUnswitching(int[] array, boolean condition) {
for (int i = 0; i < array.length; i++) {
if(condition) {
// branch1
} else {
// branch2
}
}
}
public void loopUnswitching(int[] array, boolean condition) {
if(condition) {
for (int i = 0; i < array.length; i++) {
// branch1
}
} else {
for (int i = 0; i < array.length; i++) {
// branch2
}
}
}
public void escapeAnalysis() {
BooleanContainer obj = new BooleanContainer(false);
// ...
}
class BooleanContainer {
boolean f;
}
public void escapeAnalysis() {
// equivalent to boolean b = false;
// ...
}
8 bytes
Compressed
oop
obj1
obj2
. . .
•
•
• Allocate and deallocate memory to the program
• Determine areas of heap memory that are used by the program
• Free unused memory to be reused for subsequent allocations
• Available GC algorithms in HotSpot:
1. Serial collector (-XX:+UseSerialGC)
2. Parallel collector (-XX:+UseParallelGC)
3. Concurrent Mark Sweep (CMS) collector (-XX:+UseConcMarkSweepGC)
4. G1 collector (-XX:+UseG1GC) (default since Java 9)
• All collectors parallelize their workload, except the serial GC
• Serial collector is suitable for small programs: heap size < 100 MB
• G1 is suitable for large, multithreaded programs running on a machine with high
amount of memory
• Measured in three key aspects:
1. Pause time: time it takes to stop the application and run GC
Controlled using -XX:MaxGCPauseMillis=millis
2. Throughput: ratio of GC time / application time
Controlled using -XX:GCTimeRatio=nn
 Maximum 1 / (1 + nn) of the application execution time be spent in the
collector
e.g. value of 19 means desired GC time ratio is 1/20 or 5%
3. Footprint: size of heap. GC can adjust heap size based on behavior
• There is usually a trade-off between pause time and throughput
• High throughput is suitable for a web server
• Short pause time is suitable for GUI application
• In an ideal situation the heap will grow to a value (less than the maximum) that will support
the chosen throughput goal.
• -verbose:gc or (-XX:+PrintGC) can be used to print GC messages
• -XX:-PrintGCDetails for more details
• Heap memory is composed of generations holding objects by age:
1. Young generation
2. Old generation
• Young gen triggers minor collection; old gen triggers major collection
Young gen
Eden
S
1
S
2
Old gen
Serial GC
generational
collection
Minor GC Major GC
• Unless you have problems with pauses, try granting as much memory as possible to the virtual
machine. The default size is often too small.
• Setting -Xms and -Xmx to the same value increases predictability by removing the most
important sizing decision from the virtual machine. However, the virtual machine is then unable
to compensate if you make a poor choice.
• In general, increase the memory as you increase the number of processors, because allocation
can be made parallel.
–XX:NewRatio: Ratio of old/new generation sizes. The default value is 2.
-XX:MinHeapFreeRatio=40: Minimum percentage of heap free after GC to avoid expansion.
-XX:MaxHeapFreeRatio=70: Maximum percentage of heap free after GC to avoid shrinking.
• Default GC for server VM (until Java 9)
• Uses multiple threads to collect unused memory
• Number of threads used for GC is a fraction of hardware threads (hardware configuration). It can
be changed using -XX:ParallelGCThreads=<N>
• Goal priority:
1. maximum pause-time goal
2. throughput goal
3. footprint goal
• Throws OutOfMemoryError in > 98% of time spent on GC and < 2% of object heap is claimed
(GC overhead limit)
• jcmd:
 Identify Java process
 Heap / thread dump
 View internal stats
• JVisualVM
• jmap
• JConsole
Beirut Java User Group JVM presentation

More Related Content

What's hot

Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Alexey Fyodorov
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunningguest1f2740
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCanSecWest
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015NAVER / MusicPlatform
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiCysinfo Cyber Security Community
 
DevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The CoversDevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The CoversSimon Maple
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеPlatonov Sergey
 
Multithreading done right
Multithreading done rightMultithreading done right
Multithreading done rightPlatonov Sergey
 
Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014Mark Rees
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortStefan Marr
 
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Stefan Marr
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsAndrei Pangin
 
200 Open Source Projects Later: Source Code Static Analysis Experience
200 Open Source Projects Later: Source Code Static Analysis Experience200 Open Source Projects Later: Source Code Static Analysis Experience
200 Open Source Projects Later: Source Code Static Analysis ExperienceAndrey Karpov
 
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugVk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugketan_patel25
 
An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAbhishek Asthana
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPrashant Rane
 
Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Marcos García
 
Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage CollectionHaim Yadid
 
JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020Joseph Kuo
 

What's hot (20)

Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)Counter Wars (JEEConf 2016)
Counter Wars (JEEConf 2016)
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
 
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
서버 개발자가 바라 본 Functional Reactive Programming with RxJava - SpringCamp2015
 
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul PillaiA look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
 
DevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The CoversDevoxxPL: JRebel Under The Covers
DevoxxPL: JRebel Under The Covers
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемые
 
Multithreading done right
Multithreading done rightMultithreading done right
Multithreading done right
 
Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014Seeing with Python presented at PyCon AU 2014
Seeing with Python presented at PyCon AU 2014
 
Building High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low EffortBuilding High-Performance Language Implementations With Low Effort
Building High-Performance Language Implementations With Low Effort
 
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
Zero-Overhead Metaprogramming: Reflection and Metaobject Protocols Fast and w...
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
 
200 Open Source Projects Later: Source Code Static Analysis Experience
200 Open Source Projects Later: Source Code Static Analysis Experience200 Open Source Projects Later: Source Code Static Analysis Experience
200 Open Source Projects Later: Source Code Static Analysis Experience
 
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtugVk.amberfog.com gtug part1_introduction2_javaandroid_gtug
Vk.amberfog.com gtug part1_introduction2_javaandroid_gtug
 
An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in Java
 
Pune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCDPune-Cocoa: Blocks and GCD
Pune-Cocoa: Blocks and GCD
 
Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)
 
Hello scala
Hello scalaHello scala
Hello scala
 
Let's talk about Garbage Collection
Let's talk about Garbage CollectionLet's talk about Garbage Collection
Let's talk about Garbage Collection
 
JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020JCConf 2020 - New Java Features Released in 2020
JCConf 2020 - New Java Features Released in 2020
 

Similar to Beirut Java User Group JVM presentation

Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance TunningTerry Cho
 
More topics on Java
More topics on JavaMore topics on Java
More topics on JavaAhmed Misbah
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeKenneth Geisshirt
 
JVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixJVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixCodemotion Tel Aviv
 
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
 
Goroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoGoroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoYu-Shuan Hsieh
 
.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5aminmesbahi
 
JavaTutorials.ppt
JavaTutorials.pptJavaTutorials.ppt
JavaTutorials.pptKhizar40
 
Memory Management & Garbage Collection
Memory Management & Garbage CollectionMemory Management & Garbage Collection
Memory Management & Garbage CollectionAbhishek Sur
 
Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1상욱 송
 

Similar to Beirut Java User Group JVM presentation (20)

Jvm internals
Jvm internalsJvm internals
Jvm internals
 
GC in C#
GC in C#GC in C#
GC in C#
 
Valgrind
ValgrindValgrind
Valgrind
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
More topics on Java
More topics on JavaMore topics on Java
More topics on Java
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native code
 
JVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, WixJVM Memory Model - Yoav Abrahami, Wix
JVM Memory Model - Yoav Abrahami, Wix
 
Heap & thread dump
Heap & thread dumpHeap & thread dump
Heap & thread dump
 
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...
 
Goroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoGoroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in Go
 
.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5.NET Core, ASP.NET Core Course, Session 5
.NET Core, ASP.NET Core Course, Session 5
 
[BGOUG] Java GC - Friend or Foe
[BGOUG] Java GC - Friend or Foe[BGOUG] Java GC - Friend or Foe
[BGOUG] Java GC - Friend or Foe
 
JavaTutorials.ppt
JavaTutorials.pptJavaTutorials.ppt
JavaTutorials.ppt
 
Clonedigger-Python
Clonedigger-PythonClonedigger-Python
Clonedigger-Python
 
Memory Management & Garbage Collection
Memory Management & Garbage CollectionMemory Management & Garbage Collection
Memory Management & Garbage Collection
 
Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1Java 어플리케이션 성능튜닝 Part1
Java 어플리케이션 성능튜닝 Part1
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
Jvm memory model
Jvm memory modelJvm memory model
Jvm memory model
 
java training faridabad
java training faridabadjava training faridabad
java training faridabad
 
How to fake_properly
How to fake_properlyHow to fake_properly
How to fake_properly
 

Recently uploaded

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Recently uploaded (20)

Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 

Beirut Java User Group JVM presentation

  • 4.
  • 13. •  Finding class representation and creating runtime representation of class in the JVM (in the method area)  Done by a class loader, and triggered by another type referencing the class in its run-time constant pool
  • 14. •  Bootstrap class loader (built into the JVM)  User-defined class loaders (subclass of ClassLoader) • • 1. Its fully qualified name 2. Its defining class loader
  • 15. •  verifying correct structure of class representation  creating and initializing static fields  Resolves symbolic references from the constant pool  Examples: iconst_0 istore_0 aload_0  VerifyError due to wrong type
  • 16. •  Triggered upon execution of new, getstatic, putstatic, invokestatic; or upon initialization of a subclass  JVM synchronizes the initialization to avoid multiple threads initializing the same class or recursive initialization.
  • 17. ClassFile { magic (4 bytes) minor_version (2 bytes) major_version (2 bytes) constant_pool_count (2 bytes) constant_pool[constant_pool_count-1] (cp_info structure) access_flags (2 bytes) this_class (2 bytes) super_class (2 bytes) interfaces_count (2 bytes) interfaces[interfaces_count] (2 bytes) fields_count (2 bytes) fields[fields_count] (field_info structure) methods_count (2 bytes) methods[methods_count] (method_info structure) attributes_count (2 bytes) attributes[attributes_count] (attribute_info structure) } Stream of bytes stored in big-endian format, without padding or alignment
  • 18. • Acts as a symbol table containing constants and symbolic references to classes, fields and methods • Every entry has the syntax: • CONSTANT_Utf8, CONSTANT_Integer, CONSTANT_Float, CONSTANT_Long, CONSTANT_Double, CONSTANT_Class, CONSTANT_String, CONSTANT_Fieldref, CONSTANT_Methodref, CONSTANT_MethodType, CONSTANT_Package, CONSTANT_Module, … • Example: CONSTANT_MethodType_info String toString(int x) tag entry_info (1 byte) (>= 2 bytes) 16 -> (I)Ljava/lang/String; (tag) (index to method descriptor)
  • 19. access_flags (2 bytes) name_index (2 bytes) descriptor_index (2 bytes) attributes_count (2 bytes) attributes[attributes_count] (attribute_info) • Access flags: ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_VOLATILE, ACC_TRANSIENT, ACC_SYNTHETIC, ACC_ENUM
  • 20. access_flags (2 bytes) name_index (2 bytes) descriptor_index (2 bytes) attributes_count (2 bytes) attributes[attributes_count] (attribute_info) • Access flags: ACC_PUBLIC, ACC_PRIVATE, ACC_PROTECTED, ACC_STATIC, ACC_FINAL, ACC_SYNCHRONIZED, ACC_BRIDGE, ACC_VARARGS, ACC_NATIVE, ACC_ABSTRACT, ACC_STRICT, ACC_SYNTHETIC
  • 22. objectref invokevirtual indexbyte1 indexbyte2 Invokes an instance method based on the object reference on the operand stack 1. indexbyte1 and indexbyte2 are used to fetch method from constant pool 2. The method is looked up from the class containing the method 3. The actual method invoked depends on the actual class C of objectref (could be declared in C, its superclass or superinterfaces) arg2 arg1 objectref . . . New frame . . . arg1 arg2 Local variables
  • 23. invokestatic indexbyte1 indexbyte2 Invokes a static method based  indexbyte1 and indexbyte2 are used to fetch method from constant pool  Class or interface declaring the method is initialized if not already done arg2 arg1 (double) . . . New frame . . . arg1 arg2 Local variables arg1 arg1
  • 24. invokespecial indexbyte1 indexbyte2 Invokes:  private methods  methods on superclass  instance initialization methods (<init>) objectref arg2 arg1 objectref . . . New frame . . . arg1 arg2 Local variables
  • 25. invokeinterface indexbyte1 indexbyte2 count 0 Invokes interface methods  count contains number of arguments (for historical reasons) objectref arg2 arg1 objectref . . . New frame . . . arg1 arg2 Local variables
  • 27.
  • 28.
  • 30. public void foo() { int sum = add(8, 10); // ... } public int add(int x, int y) { return x + y; } -XX:InlineSmallCode=n -XX:MaxInlineSize=35 -XX:FreqInlineSize=n
  • 31. public void foo() { int[] input = getInput(); int value = computeValue(input); // we don’t use value } public int computeValue(int[] array) { ... }
  • 32. public void loopInvariantHosting(int size) { for (int i = 0; i < 1000; i++) { int x = 3; int result = size * x; // ... } } public void loopInvariantHosting(int size) { int x = 3; int result = size * x; for (int i = 0; i < 1000; i++) { // ... } }
  • 33. public void loopUnswitching(int[] array, boolean condition) { for (int i = 0; i < array.length; i++) { if(condition) { // branch1 } else { // branch2 } } } public void loopUnswitching(int[] array, boolean condition) { if(condition) { for (int i = 0; i < array.length; i++) { // branch1 } } else { for (int i = 0; i < array.length; i++) { // branch2 } } }
  • 34. public void escapeAnalysis() { BooleanContainer obj = new BooleanContainer(false); // ... } class BooleanContainer { boolean f; } public void escapeAnalysis() { // equivalent to boolean b = false; // ... }
  • 35.
  • 38. • Allocate and deallocate memory to the program • Determine areas of heap memory that are used by the program • Free unused memory to be reused for subsequent allocations • Available GC algorithms in HotSpot: 1. Serial collector (-XX:+UseSerialGC) 2. Parallel collector (-XX:+UseParallelGC) 3. Concurrent Mark Sweep (CMS) collector (-XX:+UseConcMarkSweepGC) 4. G1 collector (-XX:+UseG1GC) (default since Java 9) • All collectors parallelize their workload, except the serial GC • Serial collector is suitable for small programs: heap size < 100 MB • G1 is suitable for large, multithreaded programs running on a machine with high amount of memory
  • 39. • Measured in three key aspects: 1. Pause time: time it takes to stop the application and run GC Controlled using -XX:MaxGCPauseMillis=millis 2. Throughput: ratio of GC time / application time Controlled using -XX:GCTimeRatio=nn  Maximum 1 / (1 + nn) of the application execution time be spent in the collector e.g. value of 19 means desired GC time ratio is 1/20 or 5% 3. Footprint: size of heap. GC can adjust heap size based on behavior
  • 40. • There is usually a trade-off between pause time and throughput • High throughput is suitable for a web server • Short pause time is suitable for GUI application • In an ideal situation the heap will grow to a value (less than the maximum) that will support the chosen throughput goal. • -verbose:gc or (-XX:+PrintGC) can be used to print GC messages • -XX:-PrintGCDetails for more details
  • 41. • Heap memory is composed of generations holding objects by age: 1. Young generation 2. Old generation • Young gen triggers minor collection; old gen triggers major collection Young gen Eden S 1 S 2 Old gen Serial GC generational collection Minor GC Major GC
  • 42. • Unless you have problems with pauses, try granting as much memory as possible to the virtual machine. The default size is often too small. • Setting -Xms and -Xmx to the same value increases predictability by removing the most important sizing decision from the virtual machine. However, the virtual machine is then unable to compensate if you make a poor choice. • In general, increase the memory as you increase the number of processors, because allocation can be made parallel. –XX:NewRatio: Ratio of old/new generation sizes. The default value is 2. -XX:MinHeapFreeRatio=40: Minimum percentage of heap free after GC to avoid expansion. -XX:MaxHeapFreeRatio=70: Maximum percentage of heap free after GC to avoid shrinking.
  • 43. • Default GC for server VM (until Java 9) • Uses multiple threads to collect unused memory • Number of threads used for GC is a fraction of hardware threads (hardware configuration). It can be changed using -XX:ParallelGCThreads=<N> • Goal priority: 1. maximum pause-time goal 2. throughput goal 3. footprint goal • Throws OutOfMemoryError in > 98% of time spent on GC and < 2% of object heap is claimed (GC overhead limit)
  • 44.
  • 45. • jcmd:  Identify Java process  Heap / thread dump  View internal stats • JVisualVM • jmap • JConsole

Editor's Notes

  1. Les volumes explosent, les latences se réduisent de plus en plus pour rester compétitif, respecter les réglementations (et éviter la prochaine crise financière) … Par exemple, on fait du Big Data, du calcul sur GPU, du calcul In-Memory. Le métier de la finance reste tout aussi riche qu’avant. Si vous aimez faire de la modélisation métier, c’est un domaine de rêve pour appliquer des techniques comme le BDD ou le DDD. Juste quelque chiffres, Murex c’est 17 bureaux avec 2000 personnes dont 350 devs dans le monde, répartis entre Paris, Beyrouth, Dublin New York et Singapour. On cherche des bons devs ! Venez nous parler à la pause ou allez faire un tour sur notre site si vous êtes intéressés.
  2. Frame size is implementation-specific, but depends on method (number of local variables, depth needed for intermediate operands)