SlideShare a Scribd company logo
1 of 27
Inside the JVM
STRUCTURE OF JAVA VIRTUAL MACHINE
Development Center @ Pikicast.com
김병부 ( Benjamin )
Benjamin
: about me
 Pikicast
 Netmarble
 U-Angel
 Joins.com and etc
因果關係
: 인과관계
 System Crash, Service Crash. Application Crash
 서비스가 죽는 것은 항상 원인이 있습니다
 시스템이 원인인지, 어플리케이션이 원인인지, 데이터 베이스가 원인인지
알아야 같은 현상을 막을 수 있습니다.
 서비스는 한번에 죽지 않습니다. 서서히 죽어갈 뿐입니다.
List of JVM
 List of JVM??
 The Java Virtual Machine Specification
 Hotspot JVM
 Open JVM
 IBM JVM
 TinyVM
 Dalvik JM ??
 Stack Machine vs Register Machine
JVM
: Java Virtual Machine #1
 Class File
 Bytecode 의 집합
 Interpreter / JIT Compiler
 Java Stack
 Heap
 Thread 들이 공유하는 메모리 영역
 Method Area
 Thread 들이 공유하는 메모리 영역
 Class 변수, 상수, Class 정보, Method 정보
Thread
1st Keyword inside of the JVM
Thread State
: java.lang.Thread.State
 NEW
 RUNNABLE
 TIMED_WAITING
 WAITING
 BLOCKED
 TERMINATED
 Since Java 1.5
Thread
:list of thread in the Hotspot JVM
 Thread 종류
 Non – Daemon Thread :
 E.g. Thread, VM Thread
 Daemon Thread :
 Garbage Collector Thread, JMX Monitoring Thread
 System Threads
 VM thread
 GC threads
 Periodic task thread – timer events i.e. interrupts for schedule
 Compiler thread – compiles byte code to native code in runtime
Thread
: Multi-Thread
 Each thread has ..
 Program Counter (PC)
 Stack
 Native stack
 Stack Frame
 Multi Thread – Context Switching & Scheduling
 Thread-Safe
 Keyword – synchronized
JVM Stack
 JVM Stack per Thread!!!
 Stack Frame per Method
 Local Variable Array
 Operand Stack
 Reference to Constant Pool
Thread dump
: How to dump JVM Thread
 jstack [pid] or kill –3 [pid]Thread Dump Date JVM Type, Mode
Thread name
Thread
Priority
Thread ID
Native
Thread ID
Thread STATUS
Thread STACK
info
Thread Dump Tool
: IBM Thread and Monitor Dump Analyzer for Java
Heap Area
2nd Keyword inside of the JVM
JVM Memory Structure
: with JVM options
 Basic Structure
 Depends on GC options
 Promotion
 Minor GC vs Major GC
 Young Generation
 Old and Perm Generation
 STW – Stop the world
 From Java8,
 No more PERM gen.
 Metaspace (Native Heap)
What is difference between Method
Area and PERM GEN?
 Actually the Method Area is a part of the PERM GEN
A third generation closely related to the tenured generation is the permanent generation.
The permanent generation is special because it holds data needed by the virtual machine
to describe objects that do not have an equivalence at the Java language level. For
example objects describing classes and methods are stored in the permanent generation.
Thread and Heap
: Reference from Stack to Heap
Garbage Collection
 GC options
 Serial GC, Parallel GC – Mark, Sweep, Compact
 Incremental GC
 CMS
 G1GC
CMS vs G1GC
 CMS GC
 Concurrent – Mark – Sweep GC
 more CPU,
 G1GC
 Garbage-First GC
 Region
 Recommend over 4G memory
Heap Dump
: How to dump JVM Heap
 jmap –dump:format=b,file=[file name].hprof [PID]
 JVM 메모리 사이즈 만큼의 binary 파일이 생성된다.
 Binary 파일이므로 분석툴이 필요함.
Heap Dump Tool
: IBM HeapAnalyzer Or Eclipse Memory Analyzer
OOME Case
: Out Of Memory Exception
 java.lang.OutOfMemoryError : Java heap space
 java.lang.OutOfMemoryError : PermGen space
 java.lang.OutOfMemoryError : Request array size exceeds VM limit
Conclusion
Conclusion inside of the JVM
Note
 Dump 는 10초 간격으로 3번씩 뜬다.
 Perm 영역에서도 OOM 이 발생할 수도 있다.
 Hotspot JVM > Open JVM
 Async Process 가 만능은 아님
 MultiThread 도 Pool로 관리하자
 Thread-safe and Pool Management
 우리에겐 G1GC 가 가장 맞는 케이스
 Throughput based tuning
 Response time based tuning
Reference
 http://blog.jamesdbloom.com/JVMInternals.html
 http://d2.naver.com/helloworld/1230
 http://blog.takipi.com/garbage-collectors-serial-vs-parallel-vs-cms-vs-the-g1-and-
whats-new-in-java-8/
 http://www.slideshare.net/MonicaBeckwith/garbage-first-garbage-collector-g1-gc-
migration-to-expectations-and-advanced-tuning
 http://www.poalsoft.com/blog/?p=34
Thank you

More Related Content

What's hot

[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스Dan Kang (강동한)
 
Intro to Pentesting Jenkins
Intro to Pentesting JenkinsIntro to Pentesting Jenkins
Intro to Pentesting JenkinsBrian Hysell
 
Three Lessons about Gatling and Microservices
Three Lessons about Gatling and MicroservicesThree Lessons about Gatling and Microservices
Three Lessons about Gatling and MicroservicesDragos Manolescu
 
Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch  Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch Haitham Refaat
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring SecurityDzmitry Naskou
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockitoshaunthomas999
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with SpringJoshua Long
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentationManav Prasad
 
Bdd – with cucumber and gherkin
Bdd – with cucumber and gherkinBdd – with cucumber and gherkin
Bdd – with cucumber and gherkinArati Joshi
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentationguest11106b
 
스프링 부트와 로깅
스프링 부트와 로깅스프링 부트와 로깅
스프링 부트와 로깅Keesun Baik
 
Spring boot
Spring bootSpring boot
Spring bootsdeeg
 

What's hot (20)

Selenium
SeleniumSelenium
Selenium
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
[Play.node] node.js 를 사용한 대규모 글로벌(+중국) 서비스
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Intro to Pentesting Jenkins
Intro to Pentesting JenkinsIntro to Pentesting Jenkins
Intro to Pentesting Jenkins
 
Three Lessons about Gatling and Microservices
Three Lessons about Gatling and MicroservicesThree Lessons about Gatling and Microservices
Three Lessons about Gatling and Microservices
 
Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch  Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch
 
Spring Framework - Spring Security
Spring Framework - Spring SecuritySpring Framework - Spring Security
Spring Framework - Spring Security
 
Spring data jpa
Spring data jpaSpring data jpa
Spring data jpa
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
 
Introduction to Selenium Web Driver
Introduction to Selenium Web DriverIntroduction to Selenium Web Driver
Introduction to Selenium Web Driver
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Karate DSL
Karate DSLKarate DSL
Karate DSL
 
Hibernate presentation
Hibernate presentationHibernate presentation
Hibernate presentation
 
Bdd – with cucumber and gherkin
Bdd – with cucumber and gherkinBdd – with cucumber and gherkin
Bdd – with cucumber and gherkin
 
Hibernate Presentation
Hibernate  PresentationHibernate  Presentation
Hibernate Presentation
 
Xke spring boot
Xke spring bootXke spring boot
Xke spring boot
 
스프링 부트와 로깅
스프링 부트와 로깅스프링 부트와 로깅
스프링 부트와 로깅
 
Spring boot
Spring bootSpring boot
Spring boot
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 

Viewers also liked (15)

Memory management in oracle
Memory management in oracleMemory management in oracle
Memory management in oracle
 
Inside the JVM
Inside the JVMInside the JVM
Inside the JVM
 
What is persistence in java
What is persistence in javaWhat is persistence in java
What is persistence in java
 
Jvm Architecture
Jvm ArchitectureJvm Architecture
Jvm Architecture
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
QSpiders - Memory (JVM architecture)
QSpiders - Memory (JVM architecture)QSpiders - Memory (JVM architecture)
QSpiders - Memory (JVM architecture)
 
Understanding JVM
Understanding JVMUnderstanding JVM
Understanding JVM
 
Java virtual machine
Java virtual machineJava virtual machine
Java virtual machine
 
Architecture diagram of jvm
Architecture diagram of jvmArchitecture diagram of jvm
Architecture diagram of jvm
 
JVM
JVMJVM
JVM
 
JVM- Java Virtual Machine
JVM- Java Virtual MachineJVM- Java Virtual Machine
JVM- Java Virtual Machine
 
Java-java virtual machine
Java-java virtual machineJava-java virtual machine
Java-java virtual machine
 
Chapter 2: Operating System Structures
Chapter 2: Operating System StructuresChapter 2: Operating System Structures
Chapter 2: Operating System Structures
 
Chapter 2 - Operating System Structures
Chapter 2 - Operating System StructuresChapter 2 - Operating System Structures
Chapter 2 - Operating System Structures
 

Similar to Inside the jvm

An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeOmar Bashir
 
Java Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderJava Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderIsuru Perera
 
Lecture 2 Java Virtual Machine .pptx
Lecture 2 Java Virtual Machine .pptxLecture 2 Java Virtual Machine .pptx
Lecture 2 Java Virtual Machine .pptxAnupamKumar559254
 
10 examples of hot spot jvm options in java
10 examples of hot spot jvm options in java10 examples of hot spot jvm options in java
10 examples of hot spot jvm options in javayamingd
 
Java Performance and Profiling
Java Performance and ProfilingJava Performance and Profiling
Java Performance and ProfilingWSO2
 
Debugging Native heap OOM - JavaOne 2013
Debugging Native heap OOM - JavaOne 2013Debugging Native heap OOM - JavaOne 2013
Debugging Native heap OOM - JavaOne 2013MattKilner
 
Fun with bytecode weaving
Fun with bytecode weavingFun with bytecode weaving
Fun with bytecode weavingMatthew
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaIsuru Perera
 
Introduction to Real Time Java
Introduction to Real Time JavaIntroduction to Real Time Java
Introduction to Real Time JavaDeniz Oguz
 
JVM, byte codes & jvm languages
JVM, byte codes & jvm languagesJVM, byte codes & jvm languages
JVM, byte codes & jvm languagesEdgar Espina
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderijaprr_editor
 
Web Sphere Problem Determination Ext
Web Sphere Problem Determination ExtWeb Sphere Problem Determination Ext
Web Sphere Problem Determination ExtRohit Kelapure
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunningguest1f2740
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance TunningTerry Cho
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuningJerry Kurian
 

Similar to Inside the jvm (20)

An Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and RuntimeAn Introduction to Java Compiler and Runtime
An Introduction to Java Compiler and Runtime
 
Java Performance and Using Java Flight Recorder
Java Performance and Using Java Flight RecorderJava Performance and Using Java Flight Recorder
Java Performance and Using Java Flight Recorder
 
Lecture 2 Java Virtual Machine .pptx
Lecture 2 Java Virtual Machine .pptxLecture 2 Java Virtual Machine .pptx
Lecture 2 Java Virtual Machine .pptx
 
GraalVm and Quarkus
GraalVm and QuarkusGraalVm and Quarkus
GraalVm and Quarkus
 
10 examples of hot spot jvm options in java
10 examples of hot spot jvm options in java10 examples of hot spot jvm options in java
10 examples of hot spot jvm options in java
 
Java Performance and Profiling
Java Performance and ProfilingJava Performance and Profiling
Java Performance and Profiling
 
Debugging Native heap OOM - JavaOne 2013
Debugging Native heap OOM - JavaOne 2013Debugging Native heap OOM - JavaOne 2013
Debugging Native heap OOM - JavaOne 2013
 
Taming The JVM
Taming The JVMTaming The JVM
Taming The JVM
 
Fun with bytecode weaving
Fun with bytecode weavingFun with bytecode weaving
Fun with bytecode weaving
 
Software Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in JavaSoftware Profiling: Understanding Java Performance and how to profile in Java
Software Profiling: Understanding Java Performance and how to profile in Java
 
jvm goes to big data
jvm goes to big datajvm goes to big data
jvm goes to big data
 
Introduction to Real Time Java
Introduction to Real Time JavaIntroduction to Real Time Java
Introduction to Real Time Java
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
JVM, byte codes & jvm languages
JVM, byte codes & jvm languagesJVM, byte codes & jvm languages
JVM, byte codes & jvm languages
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
 
Web Sphere Problem Determination Ext
Web Sphere Problem Determination ExtWeb Sphere Problem Determination Ext
Web Sphere Problem Determination Ext
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Temadag om-java-jamaica vm-2013-09
Temadag om-java-jamaica vm-2013-09Temadag om-java-jamaica vm-2013-09
Temadag om-java-jamaica vm-2013-09
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Inside the jvm

  • 1. Inside the JVM STRUCTURE OF JAVA VIRTUAL MACHINE Development Center @ Pikicast.com 김병부 ( Benjamin )
  • 2. Benjamin : about me  Pikicast  Netmarble  U-Angel  Joins.com and etc
  • 3. 因果關係 : 인과관계  System Crash, Service Crash. Application Crash  서비스가 죽는 것은 항상 원인이 있습니다  시스템이 원인인지, 어플리케이션이 원인인지, 데이터 베이스가 원인인지 알아야 같은 현상을 막을 수 있습니다.  서비스는 한번에 죽지 않습니다. 서서히 죽어갈 뿐입니다.
  • 4. List of JVM  List of JVM??  The Java Virtual Machine Specification  Hotspot JVM  Open JVM  IBM JVM  TinyVM  Dalvik JM ??  Stack Machine vs Register Machine
  • 5. JVM : Java Virtual Machine #1  Class File  Bytecode 의 집합  Interpreter / JIT Compiler  Java Stack  Heap  Thread 들이 공유하는 메모리 영역  Method Area  Thread 들이 공유하는 메모리 영역  Class 변수, 상수, Class 정보, Method 정보
  • 7. Thread State : java.lang.Thread.State  NEW  RUNNABLE  TIMED_WAITING  WAITING  BLOCKED  TERMINATED  Since Java 1.5
  • 8.
  • 9. Thread :list of thread in the Hotspot JVM  Thread 종류  Non – Daemon Thread :  E.g. Thread, VM Thread  Daemon Thread :  Garbage Collector Thread, JMX Monitoring Thread  System Threads  VM thread  GC threads  Periodic task thread – timer events i.e. interrupts for schedule  Compiler thread – compiles byte code to native code in runtime
  • 10. Thread : Multi-Thread  Each thread has ..  Program Counter (PC)  Stack  Native stack  Stack Frame  Multi Thread – Context Switching & Scheduling  Thread-Safe  Keyword – synchronized
  • 11. JVM Stack  JVM Stack per Thread!!!  Stack Frame per Method  Local Variable Array  Operand Stack  Reference to Constant Pool
  • 12. Thread dump : How to dump JVM Thread  jstack [pid] or kill –3 [pid]Thread Dump Date JVM Type, Mode Thread name Thread Priority Thread ID Native Thread ID Thread STATUS Thread STACK info
  • 13. Thread Dump Tool : IBM Thread and Monitor Dump Analyzer for Java
  • 14. Heap Area 2nd Keyword inside of the JVM
  • 15. JVM Memory Structure : with JVM options  Basic Structure  Depends on GC options  Promotion  Minor GC vs Major GC  Young Generation  Old and Perm Generation  STW – Stop the world  From Java8,  No more PERM gen.  Metaspace (Native Heap)
  • 16. What is difference between Method Area and PERM GEN?  Actually the Method Area is a part of the PERM GEN A third generation closely related to the tenured generation is the permanent generation. The permanent generation is special because it holds data needed by the virtual machine to describe objects that do not have an equivalence at the Java language level. For example objects describing classes and methods are stored in the permanent generation.
  • 17. Thread and Heap : Reference from Stack to Heap
  • 18. Garbage Collection  GC options  Serial GC, Parallel GC – Mark, Sweep, Compact  Incremental GC  CMS  G1GC
  • 19. CMS vs G1GC  CMS GC  Concurrent – Mark – Sweep GC  more CPU,  G1GC  Garbage-First GC  Region  Recommend over 4G memory
  • 20. Heap Dump : How to dump JVM Heap  jmap –dump:format=b,file=[file name].hprof [PID]  JVM 메모리 사이즈 만큼의 binary 파일이 생성된다.  Binary 파일이므로 분석툴이 필요함.
  • 21. Heap Dump Tool : IBM HeapAnalyzer Or Eclipse Memory Analyzer
  • 22.
  • 23. OOME Case : Out Of Memory Exception  java.lang.OutOfMemoryError : Java heap space  java.lang.OutOfMemoryError : PermGen space  java.lang.OutOfMemoryError : Request array size exceeds VM limit
  • 25. Note  Dump 는 10초 간격으로 3번씩 뜬다.  Perm 영역에서도 OOM 이 발생할 수도 있다.  Hotspot JVM > Open JVM  Async Process 가 만능은 아님  MultiThread 도 Pool로 관리하자  Thread-safe and Pool Management  우리에겐 G1GC 가 가장 맞는 케이스  Throughput based tuning  Response time based tuning
  • 26. Reference  http://blog.jamesdbloom.com/JVMInternals.html  http://d2.naver.com/helloworld/1230  http://blog.takipi.com/garbage-collectors-serial-vs-parallel-vs-cms-vs-the-g1-and- whats-new-in-java-8/  http://www.slideshare.net/MonicaBeckwith/garbage-first-garbage-collector-g1-gc- migration-to-expectations-and-advanced-tuning  http://www.poalsoft.com/blog/?p=34

Editor's Notes

  1. Java byte code is interpreted however this is not as fast as directly executing native code on the JVM’s host CPU. To improve performance the Oracle Hotspot VM looks for “hot” areas of byte code that are executed regularly and compiles these to native code. The native code is then stored in the code cache in non-heap memory. In this way the Hotspot VM tries to choose the most appropriate way to trade-off the extra time it takes to compile code verses the extra time it take to execute interpreted code.
  2. 데몬 스레드는 다른 비데몬 스레드가 없다면 동작을 중지한다. 사용자가 직접 스레드를 생성하지 않더라도, Java 애플리케이션이 기본적으로 여러 개의 스레드를 생성한다. 대부분이 데몬 스레드인데 가비지 컬렉션이나, JMX 등의 작업을 처리하기 위한 것이다. 'static void main(String[] args)' 메서드가 실행되는 스레드는 비데몬 스레드로 생성되고, 이 스레드가 동작을 중지하면 다른 데몬 스레드도 같이 동작을 중지하게 되는 것이다. 이 main 메서드가 실행되는 스레드를 HotSpot VM에서는 VM Thread라고 부른다.
  3. Each frame contains: - Local variable array - Return value - Operand stack Reference to runtime constant pool for class of the current method Program counter – CPU 명령어 포인터
  4. Reference to Constant Pool : 각 클래스와 인터페이스의 상수뿐만 아니라, 메서드와 필드에 대한 모든 레퍼런스까지 담고 있는 테이블이다. 즉, 어떤 메서드나 필드를 참조할 때 JVM은 런타임 상수 풀을 통해 해당 메서드나 필드의 실제 메모리상 주소를 찾아서 참조한다.
  5. OLD generation == Tenured generation