SlideShare une entreprise Scribd logo
1  sur  37
Télécharger pour lire hors ligne
Garbage, Garbage Everywhere
GC Strategies for Event Processing Systems on the JVM

C. Scott Andreas
Pizza, Beer, and Tech Talks
November 17, 2011
What’s ESP / CEP?

•   Event Stream Processing
    Selecting events on dimensions among a stream of moving
    data, maintaining them for a brief period, emitting aggregations.

•   Complex Event Processing
    Identifying correlations between events, predicting trends,
    and programmatically reacting to emergent trends.
ESP and Network Analytics

•   Packet flows are event streams with many dimensions.

•   Blast them into the engine, select over the stream,
    emit aggregations based on queries.

•   Ipfix data flows in, JSON comes out.
Back of the Envelope

•   500 Mbps / sec data comes into the JVM
    xxx Mbps / sec data goes out of the JVM

•   This memory must be allocated, retained
    for processing, freed, and collected.

•   Actual allocation rates far higher than data in / out
    (Memory also used for deserializing, aggregations, etc).
Opening the Grimoire

•   GC Tuning to the rescue

•   Oracle guide with 84 -XX: options

•   Stas’s guide: 830 options (OpenJDK debug builds)

    http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

    http://stas-blogspot.blogspot.com/2011/07/most-complete-list-of-xx-options-for.html
Moment of Pause

•   Don’t touch the knobs unless you need to

•   Server defaults are a decent place to start for local development

•   Defaults shipped with Cassandra decent for bimodal GC profiles

•   Basic rule of thumb: if you’re aggressively tuning garbage
    collection, you can trade hours of frustration for ~10% gain
Generational Garbage Collection

•   Modern JVMs divide heap space up into multiple “generations.”

•   Most applications have a lot of objects which live for a very short
    time, and a lot which live (nearly) forever.

•   Generational collection enables the JVM to collect unused
    memory more efficiently by avoiding unnecessarily scanning
    heap / object graphs for references or free regions.
first attempt: “deploy the g1”
Low-Pause Collector: The G1




  v% => threshold violations. lower is better.
G1 Collector

•   Hundreds of tiny 1ms collections / second rather than
    ParNew’s ~100 - 200ms larger collections.

•   Capable of meeting ambitious pause targets.

•   Powered by a gang of threads working in parallel

    •   ...cooperating to chew through CPU like it’s free.
second attempt:
you’re gonna laugh
the unsafe
Unsafe

•   A OpenJDK/HotSpot class exposing direct access to the
    underlying VM, OS, and memory.

•   This includes the ability to allocate, manage, and free memory.

•   Perhaps we can outsmart the JVM and do a better job than it!
Learned While Astray
•   Finalization occurs in a single thread.

•   Jumping from native finalization back into Java is expensive.

•   Attempting to outsmart the garbage collector by creating
    hundreds of thousands of tiny ByteBuffers is...a thing.

•   Java’s collectors are very good at collecting garbage.
    Your home-grown in-app GC go-kart is probably not.
returning to earth ::
attempt 3[a]
Lessons from Science
•   Your rate of “freeing” must be equal to or exceed your rate of
    object allocation on the heap.

•   High rates of allocation speed up heap fragmentation,
    which compounds the problem.

•   Creating less garbage reduces your rate of allocation
    (and freeing).

•   This means less work for the garbage collector.
best way to help out the gc ::
PRODUCE LESS
  GARBAGE
Breaking out YourKit
attempt 3[b]:
responsible tuning of the old hat
Optimizing for Infant Mortality
                                                      default newgen ratios in java 6




•   Java 6 AMD64 (server) defaults to allocating
    1/3 of heap to the new gen, 2/3 to the old gen.

•   ESP/CEP workloads place tremendous pressure on the newgen.
    The vast majority of objects survive less than five seconds.

•   Experiment: Allocate 80% of heap to the new gen, set a higher
    tenuring threshold, and lean hard on the ParNew collector.
CMS Collector

•   Guardian of the tenured generation, favorite workhorse for years.

•   Primarily parallel, easier on the CPU than the G1.

•   ...But contains a significant pause phase, is less suited to
    meeting low pause targets.
ParNew Collector

•   Designed for the small, but works great in the large.
    Excellent throughput, parallel collection.

•   Can collect ~5GB in ~200ms on a quad-core Xeon w/HT.

•   200ms pause every several seconds favorable compared to
    less frequent multi-second pauses and promotion failures.
Explosions in the Barrel
“real-time” and the jvm
Real Time and the JVM

•   Real Time
    Ability to meet specific targets with low variance is critical to the
    bare minimum functionality of the product (e.g., air bags).

•   “Soft” Real Time
    Ability to meet targets important but not critical. Value of
    system’s functionality is diminished but not eliminated by delay.
Real Time and “The Pause”

•   To what extent can a system which can endure pauses of
    unpredictable duration be considered “real-time”?

•   Is it sufficient to mitigate the frequency and duration of pauses
    for a system to still deliver value as “soft real-time”?

•   Is the alternative worth the cost?
what does your app sound like?
Garbage, Garbage Everywhere
GC Strategies for Event Processing Systems on the JVM

C. Scott Andreas
Pizza, Beer, and Tech Talks
November 17, 2011

Contenu connexe

Dernier

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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
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
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
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
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
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
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 

Dernier (20)

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
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
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.
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
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)
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
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
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 

En vedette

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

En vedette (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Scott Andreas - Garbage, Garbage Everywhere: GC Strategies for Event Processing Systems on the JVM, Boundary Tech Talks 11/17/11

  • 1. Garbage, Garbage Everywhere GC Strategies for Event Processing Systems on the JVM C. Scott Andreas Pizza, Beer, and Tech Talks November 17, 2011
  • 2. What’s ESP / CEP? • Event Stream Processing Selecting events on dimensions among a stream of moving data, maintaining them for a brief period, emitting aggregations. • Complex Event Processing Identifying correlations between events, predicting trends, and programmatically reacting to emergent trends.
  • 3. ESP and Network Analytics • Packet flows are event streams with many dimensions. • Blast them into the engine, select over the stream, emit aggregations based on queries. • Ipfix data flows in, JSON comes out.
  • 4. Back of the Envelope • 500 Mbps / sec data comes into the JVM xxx Mbps / sec data goes out of the JVM • This memory must be allocated, retained for processing, freed, and collected. • Actual allocation rates far higher than data in / out (Memory also used for deserializing, aggregations, etc).
  • 5.
  • 6.
  • 7. Opening the Grimoire • GC Tuning to the rescue • Oracle guide with 84 -XX: options • Stas’s guide: 830 options (OpenJDK debug builds) http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html http://stas-blogspot.blogspot.com/2011/07/most-complete-list-of-xx-options-for.html
  • 8. Moment of Pause • Don’t touch the knobs unless you need to • Server defaults are a decent place to start for local development • Defaults shipped with Cassandra decent for bimodal GC profiles • Basic rule of thumb: if you’re aggressively tuning garbage collection, you can trade hours of frustration for ~10% gain
  • 9. Generational Garbage Collection • Modern JVMs divide heap space up into multiple “generations.” • Most applications have a lot of objects which live for a very short time, and a lot which live (nearly) forever. • Generational collection enables the JVM to collect unused memory more efficiently by avoiding unnecessarily scanning heap / object graphs for references or free regions.
  • 11. Low-Pause Collector: The G1 v% => threshold violations. lower is better.
  • 12.
  • 13. G1 Collector • Hundreds of tiny 1ms collections / second rather than ParNew’s ~100 - 200ms larger collections. • Capable of meeting ambitious pause targets. • Powered by a gang of threads working in parallel • ...cooperating to chew through CPU like it’s free.
  • 16. Unsafe • A OpenJDK/HotSpot class exposing direct access to the underlying VM, OS, and memory. • This includes the ability to allocate, manage, and free memory. • Perhaps we can outsmart the JVM and do a better job than it!
  • 17.
  • 18.
  • 19.
  • 20. Learned While Astray • Finalization occurs in a single thread. • Jumping from native finalization back into Java is expensive. • Attempting to outsmart the garbage collector by creating hundreds of thousands of tiny ByteBuffers is...a thing. • Java’s collectors are very good at collecting garbage. Your home-grown in-app GC go-kart is probably not.
  • 21. returning to earth :: attempt 3[a]
  • 22. Lessons from Science • Your rate of “freeing” must be equal to or exceed your rate of object allocation on the heap. • High rates of allocation speed up heap fragmentation, which compounds the problem. • Creating less garbage reduces your rate of allocation (and freeing). • This means less work for the garbage collector.
  • 23. best way to help out the gc ::
  • 24. PRODUCE LESS GARBAGE
  • 27. Optimizing for Infant Mortality default newgen ratios in java 6 • Java 6 AMD64 (server) defaults to allocating 1/3 of heap to the new gen, 2/3 to the old gen. • ESP/CEP workloads place tremendous pressure on the newgen. The vast majority of objects survive less than five seconds. • Experiment: Allocate 80% of heap to the new gen, set a higher tenuring threshold, and lean hard on the ParNew collector.
  • 28. CMS Collector • Guardian of the tenured generation, favorite workhorse for years. • Primarily parallel, easier on the CPU than the G1. • ...But contains a significant pause phase, is less suited to meeting low pause targets.
  • 29. ParNew Collector • Designed for the small, but works great in the large. Excellent throughput, parallel collection. • Can collect ~5GB in ~200ms on a quad-core Xeon w/HT. • 200ms pause every several seconds favorable compared to less frequent multi-second pauses and promotion failures.
  • 31.
  • 32.
  • 34. Real Time and the JVM • Real Time Ability to meet specific targets with low variance is critical to the bare minimum functionality of the product (e.g., air bags). • “Soft” Real Time Ability to meet targets important but not critical. Value of system’s functionality is diminished but not eliminated by delay.
  • 35. Real Time and “The Pause” • To what extent can a system which can endure pauses of unpredictable duration be considered “real-time”? • Is it sufficient to mitigate the frequency and duration of pauses for a system to still deliver value as “soft real-time”? • Is the alternative worth the cost?
  • 36. what does your app sound like?
  • 37. Garbage, Garbage Everywhere GC Strategies for Event Processing Systems on the JVM C. Scott Andreas Pizza, Beer, and Tech Talks November 17, 2011