SlideShare uma empresa Scribd logo
1 de 48
Baixar para ler offline
Copyright 2018 Kirk Pepperdine
MEMORY
THE TROUBLE WITH
Copyright 2018 Kirk Pepperdine
jClarity
▸ Kirk Pepperdine
▸ Author of jPDM, a performance diagnostic model
▸ Author of the original Java Performance Tuning workshop
▸ Co-founded jClarity
▸ Building the smart generation of performance diagnostic tooling
▸ Bring predictability into the diagnostic process
▸ Co-founded JCrete
▸ The hottest unconference on the planet
▸ Java Champion(s)
OUR MARKETING SLIDE
Copyright 2018 Kirk Pepperdine
jClarity
What is your performance trouble spot
Copyright 2018 Kirk Pepperdine
jClarity
> 70% of all applications are bottlenecked
on memory
Copyright 2018 Kirk Pepperdine
jClarity
and no,

Garbage Collection

is not a fault!!!!
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
Spring Boot
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
Cassandra
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
Cassandra
or any big nosql solution
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
Apache Spark
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
Apache Spark
or any big data framework
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
Log4J
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
Log4J
or any Java logging framework
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
JSON
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
JSON
With almost any Marshalling protocol
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
ECom caching products
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
ECom caching products
Hibernate
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
ECom caching products
Hibernate
and so on
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
ECom caching products
Hibernate
and so on
and so on
Copyright 2018 Kirk Pepperdine
DO YOU USE
jClarity
ECom caching products
Hibernate
and so on
and so on
and so on
Copyright 2018 Kirk Pepperdine
jClarity
then you are very likely in this 70%
Copyright 2018 Kirk Pepperdine
Copyright 2018 Kirk Pepperdine
PROBLEMS
▸ High memory churn rates
▸many temporary objects
▸ Large live data set size
▸inflated live data set size
▸ loitering
▸ Unstable live data set size
▸memory leak
jClarity
Copyright 2018 Kirk Pepperdine
WAR STORIES
▸ Reduced allocation rates from 1.8gb/sec to 0
▸tps jumped from 400,000 to 25,000,000!!!
▸ Stripped all logging our of a transactional engine
▸Throughput jumped by a factor of 4x
▸ Wrapped 2 logging statements in a web socket framework
▸Memory churn reduced by a factor of 2
jClarity
Copyright 2018 Kirk Pepperdine
ALLOCATION SITE
jClarity
Foo foo = new Foo();
forms an allocation site
0: new #2 // class java/lang/Object
2: dup
4: invokespecial #1 // Method java/lang/Object."<init>":()V
▸Allocation will (mostly) occur in Java heap
▸ fast path
▸ slow path
▸ small objects maybe optimized to an on-stack allocation
Copyright 2018 Kirk Pepperdine
JAVA HEAP
jClarity
Eden Survivor (to) Tenured
Java Heap
▸ Java Heap is made of;
▸ Eden - nursery
▸ Survivor - intermediate pool designed to delay promotion
▸ Tenured - to hold long lived data
▸ Each space contributes to a different set of problems
▸ All affect GC overhead
Copyright 2018 Kirk Pepperdine
EDEN ALLOCATIONS
jClarity
top of heap pointer
Copyright 2018 Kirk Pepperdine
OBJECT ALLOCATION
jClarity
top of heap pointer
Foo foo = new Foo();

Bar bar = new Bar();

byte[] array = new byte[N];
Copyright 2018 Kirk Pepperdine
OBJECT ALLOCATION
jClarity
top of heap pointer
Foo foo = new Foo();

Bar bar = new Bar();

byte[] array = new byte[N];

Foo
Copyright 2018 Kirk Pepperdine
OBJECT ALLOCATION
jClarity
top of heap pointer
Foo foo = new Foo();

Bar bar = new Bar();

byte[] array = new byte[N];

Foo Bar
Copyright 2018 Kirk Pepperdine
OBJECT ALLOCATION
jClarity
top of heap pointer
Foo foo = new Foo();

Bar bar = new Bar();

byte[] array = new byte[N];

Foo Bar byte[]
Copyright 2018 Kirk Pepperdine
OBJECT ALLOCATION
jClarity
top of heap pointer
Foo Bar byte[]
▸ In multi-threaded apps, top of heap pointer must be surrounded by barriers
▸single threads allocation
▸hot memory address
▸ solved by stripping (Thread local allocation blocks)
Copyright 2018 Kirk Pepperdine
TLAB ALLOCATION
jClarity
top of heap pointer
▸ Assume 2 threads
▸each thread will have it’s own (set of) TLAB(s)
TLAB TLAB
TLAB pointerTLAB pointer
Copyright 2018 Kirk Pepperdine
TLAB ALLOCATIONS
jClarity
▸ Thread 1 -> Foo foo = new Foo(); byte[] array = new byte[N];
▸byte[] doesn’t fit in a TLAB
▸ Thread 2 -> Bar bar = new Bar();
byte[]TLAB TLAB
Foo Bar
TLAB pointerTLAB pointer
top of heap pointer
Copyright 2018 Kirk Pepperdine
TLAB WASTE %
jClarity
▸ Allocation failure to prevent buffer overflow
▸ waste up to 1% of a TLAB
FooFoo Foo Foo Foo Foo Foo Foo
Copyright 2018 Kirk Pepperdine
TLAB WASTE %
jClarity
▸ Allocation failure to prevent buffer overflow
▸ waste up to 1% of a TLAB
Foo Foo Foo Foo Foo Foo Foo Foo
Foo
Copyright 2018 Kirk Pepperdine
TENURED SPACE
jClarity
▸ Allocations in tenured make use of a free list
▸free list allocation is ~10x the cost of bump and run
▸ Data in tenured tends to be long lived
▸amount of data in tenured do affect GC pause times
Bar Bar Foo Foo
Free List
Copyright 2018 Kirk Pepperdine
PROBLEMS
▸ High memory churn rates
▸many temporary objects
jClarity
Copyright 2018 Kirk Pepperdine
PROBLEMS
▸ High memory churn rates
▸many temporary objects
jClarity
▸Quickly fill Eden
▸ frequent young gc cycles
▸ speeds up aging
▸ premature promotion
▸more frequent tenured cycles
▸increased copy costs
▸increased heap fragmentation
▸Allocation is quick
▸ quick * large number = slow
Copyright 2018 Kirk Pepperdine
REDUCING ALLOCATIONS
jClarity
> 1gb/sec
< 300mb/sec
sizeofgain
Copyright 2018 Kirk Pepperdine
PROBLEMS
▸ High memory churn rates
▸many temporary objects
▸Large live data set size
▸ inflated live data set size
▸loitering
jClarity
Copyright 2018 Kirk Pepperdine
PROBLEMS
▸ High memory churn rates
▸many temporary objects
▸Large live data set size
▸ inflated live data set size
▸loitering
jClarity
▸inflated scan for root times
▸reduced page locality
▸Inflated compaction times
▸ increase copy costs
▸ likely less space to copy too
Copyright 2018 Kirk Pepperdine
PAUSE VS OCCUPANCY
jClarity
Copyright 2018 Kirk Pepperdine
PROBLEMS
▸ High memory churn rates
▸many temporary objects
▸Large live data set size
▸ inflated live data set size
▸loitering
▸Unstable live data set size
▸ memory leak
jClarity
Copyright 2018 Kirk Pepperdine
PROBLEMS
▸ High memory churn rates
▸many temporary objects
▸Large live data set size
▸ inflated live data set size
▸loitering
▸Unstable live data set size
▸ memory leak
jClarity
▸Eventually you run out of heap
space
▸ each app thread throws an
OutOfMemoryError and
terminates
▸JVM will shutdown with all non-
daemon threads terminate
Copyright 2018 Kirk Pepperdine
jClarity
Escape Analysis
Copyright 2018 Kirk Pepperdine
Demo time
jClarity
Copyright 2018 Kirk Pepperdine
TEXT
TITLE TEXT
▸ Body Level One
▸ Body Level Two
▸ Body Level Three
▸ Body Level Four
▸ Body Level Five
Ask out my Java Performance Tuning Workshop
Send us a Java 11 GC log or
tweet about @jclarity
and #censum
and
receive a free Censum License

Mais conteúdo relacionado

Mais procurados

Hadoop world g1_gc_forh_base_v4
Hadoop world g1_gc_forh_base_v4Hadoop world g1_gc_forh_base_v4
Hadoop world g1_gc_forh_base_v4
YanpingWang
 

Mais procurados (20)

OPTIMIZING THE TICK STACK
OPTIMIZING THE TICK STACKOPTIMIZING THE TICK STACK
OPTIMIZING THE TICK STACK
 
"Enabling Googley microservices with gRPC" at JEEConf 2017
"Enabling Googley microservices with gRPC" at JEEConf 2017"Enabling Googley microservices with gRPC" at JEEConf 2017
"Enabling Googley microservices with gRPC" at JEEConf 2017
 
Java Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Java Garbage Collectors – Moving to Java7 Garbage First (G1) CollectorJava Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
Java Garbage Collectors – Moving to Java7 Garbage First (G1) Collector
 
Shooting the Rapids: Getting the Best from Java 8 Streams
Shooting the Rapids: Getting the Best from Java 8 StreamsShooting the Rapids: Getting the Best from Java 8 Streams
Shooting the Rapids: Getting the Best from Java 8 Streams
 
Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...
Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...
Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...
 
Let's Get to the Rapids
Let's Get to the RapidsLet's Get to the Rapids
Let's Get to the Rapids
 
Shooting the Rapids
Shooting the RapidsShooting the Rapids
Shooting the Rapids
 
Hadoop world g1_gc_forh_base_v4
Hadoop world g1_gc_forh_base_v4Hadoop world g1_gc_forh_base_v4
Hadoop world g1_gc_forh_base_v4
 
-XX:+UseG1GC
-XX:+UseG1GC-XX:+UseG1GC
-XX:+UseG1GC
 
Diefficiency Metrics: Measuring the Continuous Efficiency of Query Processing...
Diefficiency Metrics: Measuring the Continuous Efficiency of Query Processing...Diefficiency Metrics: Measuring the Continuous Efficiency of Query Processing...
Diefficiency Metrics: Measuring the Continuous Efficiency of Query Processing...
 
"Enabling Googley microservices with gRPC." at Devoxx France 2017
"Enabling Googley microservices with gRPC." at Devoxx France 2017"Enabling Googley microservices with gRPC." at Devoxx France 2017
"Enabling Googley microservices with gRPC." at Devoxx France 2017
 
An Efficient Biological Sequence Compression Technique Using LUT and Repeat ...
An Efficient Biological Sequence Compression Technique Using  LUT and Repeat ...An Efficient Biological Sequence Compression Technique Using  LUT and Repeat ...
An Efficient Biological Sequence Compression Technique Using LUT and Repeat ...
 
"Enabling Googley microservices with gRPC" at JDK.IO 2017
"Enabling Googley microservices with gRPC" at JDK.IO 2017"Enabling Googley microservices with gRPC" at JDK.IO 2017
"Enabling Googley microservices with gRPC" at JDK.IO 2017
 
Parallel-Ready Java Code: Managing Mutation in an Imperative Language
Parallel-Ready Java Code: Managing Mutation in an Imperative LanguageParallel-Ready Java Code: Managing Mutation in an Imperative Language
Parallel-Ready Java Code: Managing Mutation in an Imperative Language
 
Anais Dotis-Georgiou [InfluxData] | Learn Flux by Example | InfluxDays NA 2021
Anais Dotis-Georgiou [InfluxData] | Learn Flux by Example | InfluxDays NA 2021Anais Dotis-Georgiou [InfluxData] | Learn Flux by Example | InfluxDays NA 2021
Anais Dotis-Georgiou [InfluxData] | Learn Flux by Example | InfluxDays NA 2021
 
Hawq meets Hive - DataWorks San Jose 2017
Hawq meets Hive - DataWorks San Jose 2017Hawq meets Hive - DataWorks San Jose 2017
Hawq meets Hive - DataWorks San Jose 2017
 
Ireland OUG Meetup May 2017
Ireland OUG Meetup May 2017Ireland OUG Meetup May 2017
Ireland OUG Meetup May 2017
 
Spark + AI Summit recap jul16 2020
Spark + AI Summit recap jul16 2020Spark + AI Summit recap jul16 2020
Spark + AI Summit recap jul16 2020
 
Yarn by default (Spark on YARN)
Yarn by default (Spark on YARN)Yarn by default (Spark on YARN)
Yarn by default (Spark on YARN)
 
Low pause GC in HotSpot
Low pause GC in HotSpotLow pause GC in HotSpot
Low pause GC in HotSpot
 

Semelhante a Trouble with memory

Tarpm Clustering
Tarpm ClusteringTarpm Clustering
Tarpm Clustering
day
 
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Alexey Kharlamov
 

Semelhante a Trouble with memory (20)

Introducing illuminate
Introducing illuminateIntroducing illuminate
Introducing illuminate
 
Operating and Supporting Delta Lake in Production
Operating and Supporting Delta Lake in ProductionOperating and Supporting Delta Lake in Production
Operating and Supporting Delta Lake in Production
 
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
Flink Forward Berlin 2018: Stefan Richter - "Tuning Flink for Robustness and ...
 
Tuning Flink For Robustness And Performance
Tuning Flink For Robustness And PerformanceTuning Flink For Robustness And Performance
Tuning Flink For Robustness And Performance
 
Using Spark over Cassandra
Using Spark over CassandraUsing Spark over Cassandra
Using Spark over Cassandra
 
Data Streaming Ecosystem Management at Booking.com
Data Streaming Ecosystem Management at Booking.com Data Streaming Ecosystem Management at Booking.com
Data Streaming Ecosystem Management at Booking.com
 
Cross the streams thanks to Kafka and Flink (Christophe Philemotte, Digazu) K...
Cross the streams thanks to Kafka and Flink (Christophe Philemotte, Digazu) K...Cross the streams thanks to Kafka and Flink (Christophe Philemotte, Digazu) K...
Cross the streams thanks to Kafka and Flink (Christophe Philemotte, Digazu) K...
 
Spark Streaming Tips for Devs and Ops
Spark Streaming Tips for Devs and OpsSpark Streaming Tips for Devs and Ops
Spark Streaming Tips for Devs and Ops
 
Spark Streaming Tips for Devs and Ops by Fran perez y federico fernández
Spark Streaming Tips for Devs and Ops by Fran perez y federico fernándezSpark Streaming Tips for Devs and Ops by Fran perez y federico fernández
Spark Streaming Tips for Devs and Ops by Fran perez y federico fernández
 
stackconf 2020 | Speeding up Linux disk encryption by Ignat Korchagin
stackconf 2020 | Speeding up Linux disk encryption by Ignat Korchaginstackconf 2020 | Speeding up Linux disk encryption by Ignat Korchagin
stackconf 2020 | Speeding up Linux disk encryption by Ignat Korchagin
 
Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)Kafka to the Maxka - (Kafka Performance Tuning)
Kafka to the Maxka - (Kafka Performance Tuning)
 
Tarpm Clustering
Tarpm ClusteringTarpm Clustering
Tarpm Clustering
 
Advanced Apache Spark Meetup: How Spark Beat Hadoop @ 100 TB Daytona GraySor...
Advanced Apache Spark Meetup:  How Spark Beat Hadoop @ 100 TB Daytona GraySor...Advanced Apache Spark Meetup:  How Spark Beat Hadoop @ 100 TB Daytona GraySor...
Advanced Apache Spark Meetup: How Spark Beat Hadoop @ 100 TB Daytona GraySor...
 
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
Building large-scale analytics platform with Storm, Kafka and Cassandra - NYC...
 
London Spark Meetup Project Tungsten Oct 12 2015
London Spark Meetup Project Tungsten Oct 12 2015London Spark Meetup Project Tungsten Oct 12 2015
London Spark Meetup Project Tungsten Oct 12 2015
 
Docker architecture rework case study
Docker  architecture rework case studyDocker  architecture rework case study
Docker architecture rework case study
 
Cacheconcurrencyconsistency cassandra svcc
Cacheconcurrencyconsistency cassandra svccCacheconcurrencyconsistency cassandra svcc
Cacheconcurrencyconsistency cassandra svcc
 
Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT332) - AWS re:Inv...
Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT332) - AWS re:Inv...Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT332) - AWS re:Inv...
Metrics-Driven Performance Tuning for AWS Glue ETL Jobs (ANT332) - AWS re:Inv...
 
Z Garbage Collector
Z Garbage CollectorZ Garbage Collector
Z Garbage Collector
 
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdfBOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
BOS K8S Meetup - Finetuning LLama 2 Model on GKE.pdf
 

Último

The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 

Último (20)

%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 

Trouble with memory

  • 1. Copyright 2018 Kirk Pepperdine MEMORY THE TROUBLE WITH
  • 2. Copyright 2018 Kirk Pepperdine jClarity ▸ Kirk Pepperdine ▸ Author of jPDM, a performance diagnostic model ▸ Author of the original Java Performance Tuning workshop ▸ Co-founded jClarity ▸ Building the smart generation of performance diagnostic tooling ▸ Bring predictability into the diagnostic process ▸ Co-founded JCrete ▸ The hottest unconference on the planet ▸ Java Champion(s) OUR MARKETING SLIDE
  • 3. Copyright 2018 Kirk Pepperdine jClarity What is your performance trouble spot
  • 4. Copyright 2018 Kirk Pepperdine jClarity > 70% of all applications are bottlenecked on memory
  • 5. Copyright 2018 Kirk Pepperdine jClarity and no, Garbage Collection is not a fault!!!!
  • 6. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity
  • 7. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity Spring Boot
  • 8. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity Cassandra
  • 9. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity Cassandra or any big nosql solution
  • 10. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity Apache Spark
  • 11. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity Apache Spark or any big data framework
  • 12. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity Log4J
  • 13. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity Log4J or any Java logging framework
  • 14. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity JSON
  • 15. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity JSON With almost any Marshalling protocol
  • 16. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity ECom caching products
  • 17. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity ECom caching products Hibernate
  • 18. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity ECom caching products Hibernate and so on
  • 19. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity ECom caching products Hibernate and so on and so on
  • 20. Copyright 2018 Kirk Pepperdine DO YOU USE jClarity ECom caching products Hibernate and so on and so on and so on
  • 21. Copyright 2018 Kirk Pepperdine jClarity then you are very likely in this 70%
  • 22. Copyright 2018 Kirk Pepperdine
  • 23. Copyright 2018 Kirk Pepperdine PROBLEMS ▸ High memory churn rates ▸many temporary objects ▸ Large live data set size ▸inflated live data set size ▸ loitering ▸ Unstable live data set size ▸memory leak jClarity
  • 24. Copyright 2018 Kirk Pepperdine WAR STORIES ▸ Reduced allocation rates from 1.8gb/sec to 0 ▸tps jumped from 400,000 to 25,000,000!!! ▸ Stripped all logging our of a transactional engine ▸Throughput jumped by a factor of 4x ▸ Wrapped 2 logging statements in a web socket framework ▸Memory churn reduced by a factor of 2 jClarity
  • 25. Copyright 2018 Kirk Pepperdine ALLOCATION SITE jClarity Foo foo = new Foo(); forms an allocation site 0: new #2 // class java/lang/Object 2: dup 4: invokespecial #1 // Method java/lang/Object."<init>":()V ▸Allocation will (mostly) occur in Java heap ▸ fast path ▸ slow path ▸ small objects maybe optimized to an on-stack allocation
  • 26. Copyright 2018 Kirk Pepperdine JAVA HEAP jClarity Eden Survivor (to) Tenured Java Heap ▸ Java Heap is made of; ▸ Eden - nursery ▸ Survivor - intermediate pool designed to delay promotion ▸ Tenured - to hold long lived data ▸ Each space contributes to a different set of problems ▸ All affect GC overhead
  • 27. Copyright 2018 Kirk Pepperdine EDEN ALLOCATIONS jClarity top of heap pointer
  • 28. Copyright 2018 Kirk Pepperdine OBJECT ALLOCATION jClarity top of heap pointer Foo foo = new Foo(); Bar bar = new Bar(); byte[] array = new byte[N];
  • 29. Copyright 2018 Kirk Pepperdine OBJECT ALLOCATION jClarity top of heap pointer Foo foo = new Foo(); Bar bar = new Bar(); byte[] array = new byte[N]; Foo
  • 30. Copyright 2018 Kirk Pepperdine OBJECT ALLOCATION jClarity top of heap pointer Foo foo = new Foo(); Bar bar = new Bar(); byte[] array = new byte[N]; Foo Bar
  • 31. Copyright 2018 Kirk Pepperdine OBJECT ALLOCATION jClarity top of heap pointer Foo foo = new Foo(); Bar bar = new Bar(); byte[] array = new byte[N]; Foo Bar byte[]
  • 32. Copyright 2018 Kirk Pepperdine OBJECT ALLOCATION jClarity top of heap pointer Foo Bar byte[] ▸ In multi-threaded apps, top of heap pointer must be surrounded by barriers ▸single threads allocation ▸hot memory address ▸ solved by stripping (Thread local allocation blocks)
  • 33. Copyright 2018 Kirk Pepperdine TLAB ALLOCATION jClarity top of heap pointer ▸ Assume 2 threads ▸each thread will have it’s own (set of) TLAB(s) TLAB TLAB TLAB pointerTLAB pointer
  • 34. Copyright 2018 Kirk Pepperdine TLAB ALLOCATIONS jClarity ▸ Thread 1 -> Foo foo = new Foo(); byte[] array = new byte[N]; ▸byte[] doesn’t fit in a TLAB ▸ Thread 2 -> Bar bar = new Bar(); byte[]TLAB TLAB Foo Bar TLAB pointerTLAB pointer top of heap pointer
  • 35. Copyright 2018 Kirk Pepperdine TLAB WASTE % jClarity ▸ Allocation failure to prevent buffer overflow ▸ waste up to 1% of a TLAB FooFoo Foo Foo Foo Foo Foo Foo
  • 36. Copyright 2018 Kirk Pepperdine TLAB WASTE % jClarity ▸ Allocation failure to prevent buffer overflow ▸ waste up to 1% of a TLAB Foo Foo Foo Foo Foo Foo Foo Foo Foo
  • 37. Copyright 2018 Kirk Pepperdine TENURED SPACE jClarity ▸ Allocations in tenured make use of a free list ▸free list allocation is ~10x the cost of bump and run ▸ Data in tenured tends to be long lived ▸amount of data in tenured do affect GC pause times Bar Bar Foo Foo Free List
  • 38. Copyright 2018 Kirk Pepperdine PROBLEMS ▸ High memory churn rates ▸many temporary objects jClarity
  • 39. Copyright 2018 Kirk Pepperdine PROBLEMS ▸ High memory churn rates ▸many temporary objects jClarity ▸Quickly fill Eden ▸ frequent young gc cycles ▸ speeds up aging ▸ premature promotion ▸more frequent tenured cycles ▸increased copy costs ▸increased heap fragmentation ▸Allocation is quick ▸ quick * large number = slow
  • 40. Copyright 2018 Kirk Pepperdine REDUCING ALLOCATIONS jClarity > 1gb/sec < 300mb/sec sizeofgain
  • 41. Copyright 2018 Kirk Pepperdine PROBLEMS ▸ High memory churn rates ▸many temporary objects ▸Large live data set size ▸ inflated live data set size ▸loitering jClarity
  • 42. Copyright 2018 Kirk Pepperdine PROBLEMS ▸ High memory churn rates ▸many temporary objects ▸Large live data set size ▸ inflated live data set size ▸loitering jClarity ▸inflated scan for root times ▸reduced page locality ▸Inflated compaction times ▸ increase copy costs ▸ likely less space to copy too
  • 43. Copyright 2018 Kirk Pepperdine PAUSE VS OCCUPANCY jClarity
  • 44. Copyright 2018 Kirk Pepperdine PROBLEMS ▸ High memory churn rates ▸many temporary objects ▸Large live data set size ▸ inflated live data set size ▸loitering ▸Unstable live data set size ▸ memory leak jClarity
  • 45. Copyright 2018 Kirk Pepperdine PROBLEMS ▸ High memory churn rates ▸many temporary objects ▸Large live data set size ▸ inflated live data set size ▸loitering ▸Unstable live data set size ▸ memory leak jClarity ▸Eventually you run out of heap space ▸ each app thread throws an OutOfMemoryError and terminates ▸JVM will shutdown with all non- daemon threads terminate
  • 46. Copyright 2018 Kirk Pepperdine jClarity Escape Analysis
  • 47. Copyright 2018 Kirk Pepperdine Demo time jClarity
  • 48. Copyright 2018 Kirk Pepperdine TEXT TITLE TEXT ▸ Body Level One ▸ Body Level Two ▸ Body Level Three ▸ Body Level Four ▸ Body Level Five Ask out my Java Performance Tuning Workshop Send us a Java 11 GC log or tweet about @jclarity and #censum and receive a free Censum License