SlideShare una empresa de Scribd logo
1 de 23
Writing a simple lock profiler
on the JVM
Me
● Pierre Laporte
– Java guy at Xebia France
– JVM internals since oct-2012
– Java Performance Tuning
● @pingtimeout
● pierre@pingtimeout.fr
● http://www.pingtimeout.fr/
This talk
● Tyrion
– Lock Profiler
– Prototype
– Open Source (GPL)
– https://github.com/pingtimeout/tyrion
– Be critical !
Why a lock profiler ?
● Initial idea : GC logs parser
– for science (and fun)
● Challenged by Kirk
– Write a lock profiler
– Harder, even more fun
● My skills ?
– No idea of bytecode manipulation
– ASM means “The Assembly language”, right ?
Goals
● Create an open-source lock-profiler
● First prototype should :
– List the locks that are never accessed
– List the locks accessed by only one thread
– List the locks accessed by more than one thread
Additional goals
● Follow the GC logs approach
– Generate a log file
– Information density
– Parse & analyse it after
Big Picture
● Java Agent
– Bytecode manipulation (ASM)
– JSON output (Jackson)
● Analyser
– Console only (for now)
Implementation
● Instrument synchronized blocks/methods
– Call profiler inside critical sections
● Before the first instruction (record entry)
● After the last instruction (record exit)
– Store events per thread
– Events collection and dump
● Asynchronously
● Dedicated thread
Before/After : Synchronized blocks
synchronized(obj) {
/* Stuff */
}
synchronized(obj) {
Interceptor.enteredCriticalSection(obj);
/* Stuff */
Interceptor.leavingCriticalSection(obj);
}
Before : Synchronized blocks
ALOAD_1
MONITORENTER
/*...*/
ALOAD_1
MONITOREXIT
After : Synchronized blocks
ALOAD_1
DUP
MONITORENTER
INVOKESTATIC #3
Method fr/pingtimeout/tyrion/Interceptor
.enteredCriticalSection:(Ljava/lang/Object;)V
/*...*/
ALOAD_1
DUP
INVOKESTATIC #4
Method fr/pingtimeout/tyrion/Interceptor
.leavingCriticalSection (Ljava/lang/Object;)V
MONITOREXIT
Before/After : Synchronized
methods
synchronized void foo() {
/* Stuff */
}
synchronized void foo() {
Interceptor.enteredCriticalSection(this);
/* Stuff */
Interceptor.leavingCriticalSection(this);
}
Before : Synchronized methods
● Nothing special
– Regular methods
– Synchronization done by the JVM
● No MONITORENTER / MONITOREXIT
– Cannot intercept lock before it is held
After : Synchronized methods
// Method beginning
ALOAD_0
INVOKESTATIC #3
// Method fr/pingtimeout/tyrion/Interceptor
enteredCriticalSection:(Ljava/lang/Object;)V
/*...*/
ALOAD_0
INVOKESTATIC #4
// Method fr/pingtimeout/tyrion/Interceptor
leavingCriticalSection (Ljava/lang/Object;)V
// Method end
Before/After : Static methods
static synchronized void bar() {
/* Stuff */
}
static synchronized void bar() {
Class<?> clazz = Class.forName("FQN");
Interceptor.enteredCriticalSection(clazz);
/* Stuff */
Interceptor.leavingCriticalSection(clazz);
}
Before : Static methods
● Nothing special
– Regular methods
– Synchronization done by the JVM
● No MONITORENTER / MONITOREXIT
– Cannot intercept lock before it is held
After : Static methods
LDC #4 // Current class name known by ASM
INVOKESTATIC #2 // Method java.lang.Class.forName:
(Ljava/lang/String;)Ljava/lang/Class;
INVOKESTATIC #3 // Method fr/pingtimeout/tyrion/Interceptor
enteredCriticalSection:(Ljava/lang/Object;)V
/*...*/
LDC #4 // Current class name known by ASM
INVOKESTATIC #2 // Method java.lang.Class.forName:
(Ljava/lang/String;)Ljava/lang/Class;
INVOKESTATIC #4 // Method fr/pingtimeout/tyrion/Interceptor
leavingCriticalSection (Ljava/lang/Object;)V
After : Static methods
LDC #4
● // Current class name known by ASM
INVOKESTATIC #2
● // Method java.lang.Class.forName:
(Ljava/lang/String;)Ljava/lang/Class;
INVOKESTATIC #3
● // Method fr/pingtimeout/tyrion/Interceptor
enteredCriticalSection:(Ljava/lang/Object;)V
Drawbacks
● Only time spent inside critical section
– No "waiting on monitor" time
– Simplest (fastest) solution
● Infer "likely contended" locks
– Locks accessed by several threads
– Within millis/micros/nanos ?
Demo
● Hello World
● Cassandra Startup
Fun stuff
● Store events in a shared data structure
Map<Thread, Set<Event>> accesses;
● Infinite interception loop
synchronized(accesses) {…}
● Has to be lock-free !
– Map<Thread, AtomicReference<Set<Event>>>
● Immutable ConsList<Event>
– CAS possible
Roadmap
● Build a fancy GUI
– JavaFX ? Swing+JFreecharts ? … ?
● Use System.nanoTime()
● Densify output
● … ?
Thanks !
● Code on Github :
https://github.com/pingtimeout/tyrion
● Slides posted online
http://fr.slideshare.net/PierreLaporte
● Any questions ?

Más contenido relacionado

La actualidad más candente

Phpactor and VIM
Phpactor and VIMPhpactor and VIM
Phpactor and VIMdantleech
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?Maciej Lasyk
 
Ever Present Persistence - Established Footholds Seen in the Wild
Ever Present Persistence - Established Footholds Seen in the WildEver Present Persistence - Established Footholds Seen in the Wild
Ever Present Persistence - Established Footholds Seen in the WildCTruncer
 
We shall play a game....
We shall play a game....We shall play a game....
We shall play a game....Sadia Textile
 
Egress-Assess and Owning Data Exfiltration
Egress-Assess and Owning Data ExfiltrationEgress-Assess and Owning Data Exfiltration
Egress-Assess and Owning Data ExfiltrationCTruncer
 
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet
 
Profile all the things! - Capital Go 2017
 Profile all the things! - Capital Go 2017 Profile all the things! - Capital Go 2017
Profile all the things! - Capital Go 2017John Potocny
 

La actualidad más candente (12)

Raptor web application firewall
Raptor web application firewallRaptor web application firewall
Raptor web application firewall
 
Phpactor and VIM
Phpactor and VIMPhpactor and VIM
Phpactor and VIM
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 
Shall we play a game?
Shall we play a game?Shall we play a game?
Shall we play a game?
 
Ever Present Persistence - Established Footholds Seen in the Wild
Ever Present Persistence - Established Footholds Seen in the WildEver Present Persistence - Established Footholds Seen in the Wild
Ever Present Persistence - Established Footholds Seen in the Wild
 
We shall play a game....
We shall play a game....We shall play a game....
We shall play a game....
 
Deja vu JavaZone 2013
Deja vu  JavaZone 2013Deja vu  JavaZone 2013
Deja vu JavaZone 2013
 
Violent python
Violent pythonViolent python
Violent python
 
Egress-Assess and Owning Data Exfiltration
Egress-Assess and Owning Data ExfiltrationEgress-Assess and Owning Data Exfiltration
Egress-Assess and Owning Data Exfiltration
 
0d1n
0d1n0d1n
0d1n
 
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
 
Profile all the things! - Capital Go 2017
 Profile all the things! - Capital Go 2017 Profile all the things! - Capital Go 2017
Profile all the things! - Capital Go 2017
 

Destacado

Save JVM by Yourself: Real War Experiences of OOM
Save JVM by Yourself: Real War Experiences of OOMSave JVM by Yourself: Real War Experiences of OOM
Save JVM by Yourself: Real War Experiences of OOMLeon Chen
 
自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015)Leon Chen
 
Recipe 黃佳伶 葉愛慧
Recipe 黃佳伶 葉愛慧Recipe 黃佳伶 葉愛慧
Recipe 黃佳伶 葉愛慧10y2try
 
大型网站架构演变
大型网站架构演变大型网站架构演变
大型网站架构演变xiaozhen1900
 
Lock Interface in Java
Lock Interface in JavaLock Interface in Java
Lock Interface in JavaHome
 
浅谈项目管理(诸葛B2B电商研发部版改)
浅谈项目管理(诸葛B2B电商研发部版改)浅谈项目管理(诸葛B2B电商研发部版改)
浅谈项目管理(诸葛B2B电商研发部版改)诸葛修车网-诸葛商城
 
Thrift+scribe实现分布式日志收集,并与log4j集成
Thrift+scribe实现分布式日志收集,并与log4j集成Thrift+scribe实现分布式日志收集,并与log4j集成
Thrift+scribe实现分布式日志收集,并与log4j集成zhongbing liu
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionHaribabu Nandyal Padmanaban
 
Concurrency: Best Practices
Concurrency: Best PracticesConcurrency: Best Practices
Concurrency: Best PracticesIndicThreads
 
[Java concurrency]02.basic thread synchronization
[Java concurrency]02.basic thread synchronization[Java concurrency]02.basic thread synchronization
[Java concurrency]02.basic thread synchronizationxuehan zhu
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread poolsmaksym220889
 
淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展Leon Chen
 
On heap cache vs off-heap cache
On heap cache vs off-heap cacheOn heap cache vs off-heap cache
On heap cache vs off-heap cachergrebski
 
Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlLeon Chen
 

Destacado (20)

Nginx+tomcat https 配置
Nginx+tomcat  https 配置Nginx+tomcat  https 配置
Nginx+tomcat https 配置
 
Java多线程技术
Java多线程技术Java多线程技术
Java多线程技术
 
Git基础培训
Git基础培训Git基础培训
Git基础培训
 
App开发过程的演变之路
App开发过程的演变之路App开发过程的演变之路
App开发过程的演变之路
 
Save JVM by Yourself: Real War Experiences of OOM
Save JVM by Yourself: Real War Experiences of OOMSave JVM by Yourself: Real War Experiences of OOM
Save JVM by Yourself: Real War Experiences of OOM
 
如何更好地设计测试用例-BQConf
如何更好地设计测试用例-BQConf如何更好地设计测试用例-BQConf
如何更好地设计测试用例-BQConf
 
自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)自己的JVM自己救: 解救 OOM 實務經驗談  (JCConf 2015)
自己的JVM自己救: 解救 OOM 實務經驗談 (JCConf 2015)
 
Recipe 黃佳伶 葉愛慧
Recipe 黃佳伶 葉愛慧Recipe 黃佳伶 葉愛慧
Recipe 黃佳伶 葉愛慧
 
大型网站架构演变
大型网站架构演变大型网站架构演变
大型网站架构演变
 
Lock Interface in Java
Lock Interface in JavaLock Interface in Java
Lock Interface in Java
 
浅谈项目管理(诸葛B2B电商研发部版改)
浅谈项目管理(诸葛B2B电商研发部版改)浅谈项目管理(诸葛B2B电商研发部版改)
浅谈项目管理(诸葛B2B电商研发部版改)
 
Thrift+scribe实现分布式日志收集,并与log4j集成
Thrift+scribe实现分布式日志收集,并与log4j集成Thrift+scribe实现分布式日志收集,并与log4j集成
Thrift+scribe实现分布式日志收集,并与log4j集成
 
Performance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage CollectionPerformance Tuning - Understanding Garbage Collection
Performance Tuning - Understanding Garbage Collection
 
Concurrency: Best Practices
Concurrency: Best PracticesConcurrency: Best Practices
Concurrency: Best Practices
 
[Java concurrency]02.basic thread synchronization
[Java concurrency]02.basic thread synchronization[Java concurrency]02.basic thread synchronization
[Java concurrency]02.basic thread synchronization
 
JVM及其调优
JVM及其调优JVM及其调优
JVM及其调优
 
Java concurrency - Thread pools
Java concurrency - Thread poolsJava concurrency - Thread pools
Java concurrency - Thread pools
 
淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展
 
On heap cache vs off-heap cache
On heap cache vs off-heap cacheOn heap cache vs off-heap cache
On heap cache vs off-heap cache
 
Introduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission ControlIntroduction of Java GC Tuning and Java Java Mission Control
Introduction of Java GC Tuning and Java Java Mission Control
 

Similar a Building a lock profiler on the JVM

Java 8 and beyond, a scala story
Java 8 and beyond, a scala storyJava 8 and beyond, a scala story
Java 8 and beyond, a scala storyittaiz
 
Shall we play a game
Shall we play a gameShall we play a game
Shall we play a gamejackpot201
 
Adv java unit 1 M.Sc CS.pdf
Adv java unit 1 M.Sc CS.pdfAdv java unit 1 M.Sc CS.pdf
Adv java unit 1 M.Sc CS.pdfKALAISELVI P
 
Configuring Syslog by Octavio
Configuring Syslog by OctavioConfiguring Syslog by Octavio
Configuring Syslog by OctavioRowell Dionicio
 
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...CanSecWest
 
NSC #2 - Challenge Solution
NSC #2 - Challenge SolutionNSC #2 - Challenge Solution
NSC #2 - Challenge SolutionNoSuchCon
 
Suricata: A Decade Under the Influence (of packet sniffing)
Suricata: A Decade Under the Influence (of packet sniffing)Suricata: A Decade Under the Influence (of packet sniffing)
Suricata: A Decade Under the Influence (of packet sniffing)Jason Williams
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Sylvain Wallez
 
Sonar qube to impove code quality
Sonar qube   to impove code qualitySonar qube   to impove code quality
Sonar qube to impove code qualityMani Sarkar
 
Having fun with Raspberry(s) and Apache projects
Having fun with Raspberry(s) and Apache projectsHaving fun with Raspberry(s) and Apache projects
Having fun with Raspberry(s) and Apache projectsJean-Frederic Clere
 
A tour on Spur for non-VM experts
A tour on Spur for non-VM expertsA tour on Spur for non-VM experts
A tour on Spur for non-VM expertsESUG
 
Wonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCSWonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCSVlatko Kosturjak
 
The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9jClarity
 
Ruxmon feb 2013 what happened to rails
Ruxmon feb 2013   what happened to railsRuxmon feb 2013   what happened to rails
Ruxmon feb 2013 what happened to railssnyff
 
Understanding Non Blocking I/O with Python
Understanding Non Blocking I/O with PythonUnderstanding Non Blocking I/O with Python
Understanding Non Blocking I/O with PythonVaidik Kapoor
 
No locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructureNo locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructureAndrew Petukhov
 
.NET @ apache.org
 .NET @ apache.org .NET @ apache.org
.NET @ apache.orgTed Husted
 
Introducing OWASP OWTF Workshop BruCon 2012
Introducing OWASP OWTF Workshop BruCon 2012Introducing OWASP OWTF Workshop BruCon 2012
Introducing OWASP OWTF Workshop BruCon 2012Abraham Aranguren
 
Super Fast Gevent Introduction
Super Fast Gevent IntroductionSuper Fast Gevent Introduction
Super Fast Gevent IntroductionWalter Liu
 

Similar a Building a lock profiler on the JVM (20)

Java 8 and beyond, a scala story
Java 8 and beyond, a scala storyJava 8 and beyond, a scala story
Java 8 and beyond, a scala story
 
0507 057 01 98 * Adana Klima Servisleri
0507 057 01 98 * Adana Klima Servisleri0507 057 01 98 * Adana Klima Servisleri
0507 057 01 98 * Adana Klima Servisleri
 
Shall we play a game
Shall we play a gameShall we play a game
Shall we play a game
 
Adv java unit 1 M.Sc CS.pdf
Adv java unit 1 M.Sc CS.pdfAdv java unit 1 M.Sc CS.pdf
Adv java unit 1 M.Sc CS.pdf
 
Configuring Syslog by Octavio
Configuring Syslog by OctavioConfiguring Syslog by Octavio
Configuring Syslog by Octavio
 
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
CSW2017 Henry li how to find the vulnerability to bypass the control flow gua...
 
NSC #2 - Challenge Solution
NSC #2 - Challenge SolutionNSC #2 - Challenge Solution
NSC #2 - Challenge Solution
 
Suricata: A Decade Under the Influence (of packet sniffing)
Suricata: A Decade Under the Influence (of packet sniffing)Suricata: A Decade Under the Influence (of packet sniffing)
Suricata: A Decade Under the Influence (of packet sniffing)
 
Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!Inside the JVM - Follow the white rabbit!
Inside the JVM - Follow the white rabbit!
 
Sonar qube to impove code quality
Sonar qube   to impove code qualitySonar qube   to impove code quality
Sonar qube to impove code quality
 
Having fun with Raspberry(s) and Apache projects
Having fun with Raspberry(s) and Apache projectsHaving fun with Raspberry(s) and Apache projects
Having fun with Raspberry(s) and Apache projects
 
A tour on Spur for non-VM experts
A tour on Spur for non-VM expertsA tour on Spur for non-VM experts
A tour on Spur for non-VM experts
 
Wonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCSWonderful world of (distributed) SCM or VCS
Wonderful world of (distributed) SCM or VCS
 
The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9The Diabolical Developer's Guide to Surviving Java 9
The Diabolical Developer's Guide to Surviving Java 9
 
Ruxmon feb 2013 what happened to rails
Ruxmon feb 2013   what happened to railsRuxmon feb 2013   what happened to rails
Ruxmon feb 2013 what happened to rails
 
Understanding Non Blocking I/O with Python
Understanding Non Blocking I/O with PythonUnderstanding Non Blocking I/O with Python
Understanding Non Blocking I/O with Python
 
No locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructureNo locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructure
 
.NET @ apache.org
 .NET @ apache.org .NET @ apache.org
.NET @ apache.org
 
Introducing OWASP OWTF Workshop BruCon 2012
Introducing OWASP OWTF Workshop BruCon 2012Introducing OWASP OWTF Workshop BruCon 2012
Introducing OWASP OWTF Workshop BruCon 2012
 
Super Fast Gevent Introduction
Super Fast Gevent IntroductionSuper Fast Gevent Introduction
Super Fast Gevent Introduction
 

Más de Pierre Laporte

Leveraging chaos mesh in Astra Serverless testing
Leveraging chaos mesh in Astra Serverless testingLeveraging chaos mesh in Astra Serverless testing
Leveraging chaos mesh in Astra Serverless testingPierre Laporte
 
Les race conditions, nos très chères amies
Les race conditions, nos très chères amiesLes race conditions, nos très chères amies
Les race conditions, nos très chères amiesPierre Laporte
 
Devoxx BE - How to fail at benchmarking
Devoxx BE - How to fail at benchmarkingDevoxx BE - How to fail at benchmarking
Devoxx BE - How to fail at benchmarkingPierre Laporte
 
Lyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarkingLyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarkingPierre Laporte
 
La BDD, l'enfant gâté des SI
La BDD, l'enfant gâté des SILa BDD, l'enfant gâté des SI
La BDD, l'enfant gâté des SIPierre Laporte
 
How to fail at benchmarking?
How to fail at benchmarking?How to fail at benchmarking?
How to fail at benchmarking?Pierre Laporte
 
Pimp my gc - Supersonic Scala
Pimp my gc - Supersonic ScalaPimp my gc - Supersonic Scala
Pimp my gc - Supersonic ScalaPierre Laporte
 

Más de Pierre Laporte (7)

Leveraging chaos mesh in Astra Serverless testing
Leveraging chaos mesh in Astra Serverless testingLeveraging chaos mesh in Astra Serverless testing
Leveraging chaos mesh in Astra Serverless testing
 
Les race conditions, nos très chères amies
Les race conditions, nos très chères amiesLes race conditions, nos très chères amies
Les race conditions, nos très chères amies
 
Devoxx BE - How to fail at benchmarking
Devoxx BE - How to fail at benchmarkingDevoxx BE - How to fail at benchmarking
Devoxx BE - How to fail at benchmarking
 
Lyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarkingLyon jug-how-to-fail-at-benchmarking
Lyon jug-how-to-fail-at-benchmarking
 
La BDD, l'enfant gâté des SI
La BDD, l'enfant gâté des SILa BDD, l'enfant gâté des SI
La BDD, l'enfant gâté des SI
 
How to fail at benchmarking?
How to fail at benchmarking?How to fail at benchmarking?
How to fail at benchmarking?
 
Pimp my gc - Supersonic Scala
Pimp my gc - Supersonic ScalaPimp my gc - Supersonic Scala
Pimp my gc - Supersonic Scala
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Building a lock profiler on the JVM

  • 1. Writing a simple lock profiler on the JVM
  • 2. Me ● Pierre Laporte – Java guy at Xebia France – JVM internals since oct-2012 – Java Performance Tuning ● @pingtimeout ● pierre@pingtimeout.fr ● http://www.pingtimeout.fr/
  • 3. This talk ● Tyrion – Lock Profiler – Prototype – Open Source (GPL) – https://github.com/pingtimeout/tyrion – Be critical !
  • 4. Why a lock profiler ? ● Initial idea : GC logs parser – for science (and fun) ● Challenged by Kirk – Write a lock profiler – Harder, even more fun ● My skills ? – No idea of bytecode manipulation – ASM means “The Assembly language”, right ?
  • 5. Goals ● Create an open-source lock-profiler ● First prototype should : – List the locks that are never accessed – List the locks accessed by only one thread – List the locks accessed by more than one thread
  • 6. Additional goals ● Follow the GC logs approach – Generate a log file – Information density – Parse & analyse it after
  • 7. Big Picture ● Java Agent – Bytecode manipulation (ASM) – JSON output (Jackson) ● Analyser – Console only (for now)
  • 8. Implementation ● Instrument synchronized blocks/methods – Call profiler inside critical sections ● Before the first instruction (record entry) ● After the last instruction (record exit) – Store events per thread – Events collection and dump ● Asynchronously ● Dedicated thread
  • 9. Before/After : Synchronized blocks synchronized(obj) { /* Stuff */ } synchronized(obj) { Interceptor.enteredCriticalSection(obj); /* Stuff */ Interceptor.leavingCriticalSection(obj); }
  • 10. Before : Synchronized blocks ALOAD_1 MONITORENTER /*...*/ ALOAD_1 MONITOREXIT
  • 11. After : Synchronized blocks ALOAD_1 DUP MONITORENTER INVOKESTATIC #3 Method fr/pingtimeout/tyrion/Interceptor .enteredCriticalSection:(Ljava/lang/Object;)V /*...*/ ALOAD_1 DUP INVOKESTATIC #4 Method fr/pingtimeout/tyrion/Interceptor .leavingCriticalSection (Ljava/lang/Object;)V MONITOREXIT
  • 12. Before/After : Synchronized methods synchronized void foo() { /* Stuff */ } synchronized void foo() { Interceptor.enteredCriticalSection(this); /* Stuff */ Interceptor.leavingCriticalSection(this); }
  • 13. Before : Synchronized methods ● Nothing special – Regular methods – Synchronization done by the JVM ● No MONITORENTER / MONITOREXIT – Cannot intercept lock before it is held
  • 14. After : Synchronized methods // Method beginning ALOAD_0 INVOKESTATIC #3 // Method fr/pingtimeout/tyrion/Interceptor enteredCriticalSection:(Ljava/lang/Object;)V /*...*/ ALOAD_0 INVOKESTATIC #4 // Method fr/pingtimeout/tyrion/Interceptor leavingCriticalSection (Ljava/lang/Object;)V // Method end
  • 15. Before/After : Static methods static synchronized void bar() { /* Stuff */ } static synchronized void bar() { Class<?> clazz = Class.forName("FQN"); Interceptor.enteredCriticalSection(clazz); /* Stuff */ Interceptor.leavingCriticalSection(clazz); }
  • 16. Before : Static methods ● Nothing special – Regular methods – Synchronization done by the JVM ● No MONITORENTER / MONITOREXIT – Cannot intercept lock before it is held
  • 17. After : Static methods LDC #4 // Current class name known by ASM INVOKESTATIC #2 // Method java.lang.Class.forName: (Ljava/lang/String;)Ljava/lang/Class; INVOKESTATIC #3 // Method fr/pingtimeout/tyrion/Interceptor enteredCriticalSection:(Ljava/lang/Object;)V /*...*/ LDC #4 // Current class name known by ASM INVOKESTATIC #2 // Method java.lang.Class.forName: (Ljava/lang/String;)Ljava/lang/Class; INVOKESTATIC #4 // Method fr/pingtimeout/tyrion/Interceptor leavingCriticalSection (Ljava/lang/Object;)V
  • 18. After : Static methods LDC #4 ● // Current class name known by ASM INVOKESTATIC #2 ● // Method java.lang.Class.forName: (Ljava/lang/String;)Ljava/lang/Class; INVOKESTATIC #3 ● // Method fr/pingtimeout/tyrion/Interceptor enteredCriticalSection:(Ljava/lang/Object;)V
  • 19. Drawbacks ● Only time spent inside critical section – No "waiting on monitor" time – Simplest (fastest) solution ● Infer "likely contended" locks – Locks accessed by several threads – Within millis/micros/nanos ?
  • 20. Demo ● Hello World ● Cassandra Startup
  • 21. Fun stuff ● Store events in a shared data structure Map<Thread, Set<Event>> accesses; ● Infinite interception loop synchronized(accesses) {…} ● Has to be lock-free ! – Map<Thread, AtomicReference<Set<Event>>> ● Immutable ConsList<Event> – CAS possible
  • 22. Roadmap ● Build a fancy GUI – JavaFX ? Swing+JFreecharts ? … ? ● Use System.nanoTime() ● Densify output ● … ?
  • 23. Thanks ! ● Code on Github : https://github.com/pingtimeout/tyrion ● Slides posted online http://fr.slideshare.net/PierreLaporte ● Any questions ?