SlideShare a Scribd company logo
Improving Pharo
Snapshots
P. Tesone - G. Polito - N. Palumbo - ESUG’22
@tesonep
@guillep
@noTwitter
guillermo.polito@univ-lille.fr
pablo.tesone@inria.fr
nahuel.palumbo@inria.fr
2022 VM+ Team
2
• Numbers
• Characters
• Strings
• Arrays
• Closures
• Classes
• Methods
• …
Everythingis an Object
• Numbers
• Characters
• Strings
• Arrays
• Closures
• Classes
• Methods
• …
Everythingis an Object
• Numbers
• Characters
• Strings
• Arrays
• Closures
• Classes
• Methods
• …
Everythingis an Object
• Numbers
• Characters
• Strings
• Arrays
• Closures
• Classes
• Methods
• …
Everythingis an Object
• Numbers
• Characters
• Strings
• Arrays
• Closures
• Classes
• Methods
• …
Everythingis an Object
• Numbers
• Characters
• Strings
• Arrays
• Closures
• Classes
• Methods
• …
Lots of Objects
• Numbers
• Characters
• Strings
• Arrays
• Closures
• Classes
• Methods
• …
Lots of Objects
Lots of Stress
• GC Stress
• Autocompletion Stress
• Search Stress
• Spotter Stress
• Startup Stress
Lots of Objects
Lots of Stress
Large Image Support
• https://github.com/pharo-project/largeImages
• MIT Licenced
Large Image Support: Highlights
• Generator based searches
• Spotter
• Code Completion
• GC Fine Tuning API
generator
^ generator ifNil: [
generator := Generator on: [ :g |
self entriesDo: [ :entry |
(self acceptsEntry: entry)
ifTrue: [ g yield: entry ] ] ] ]
GC Fine Tuning
• Con
fi
gure
• Eden Size
• Full GC Ratio
• Growth Headroom
• Shrink Threshold
GCConfiguration readFromVM
fullGCRatio: 1.0;
activeDuring: [ “something" ].
• Numbers
• Characters
• Strings
• Arrays
• Closures
• Classes
• Methods
• …
Lots of Objects
• Numbers
• Characters
• Strings
• Arrays
• Closures
• Classes
• Methods
• …
Images = Heap Snapshots
.image
save
load
Heap
Snapshot Current Design Points
• Bootstrap once, then mutate
• Portable
• Object References are pointers
• Load code
• Create Objects
• Run your app
• Maybe GC!
• Repeat
.image .image
Heap
But it could be better…
• VM startup is bound by disk!
• Large heaps take long to load/save
• 3-4GB heaps = seconds to GC
• pauses
• long pauses
• Load code
• Create Objects
• Run your app
• Maybe GC!
• Repeat
.image .image
Heap
Snapshots vs Runtime Memory Mismatch
App and System Objects
Threads State
as Objects
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
.image
Current Loading Snapshot to Memory
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
Direct Mapping
Rebuild
Empty Empty
.image App and System Objects
Threads State
as Objects
Start with a cold VM,
startup is slow
Reference Swizzling
• Traverse the heap to remap old references by delta
• Slow for large heaps (2/4GB)
Hot Methods
Machine Code
Process 1 Thread
Stacks
New Objects Old Objects
Hot Methods
Machine Code
Process 2 Thread
Stacks
New Objects Old Objects
R
e
m
a
p
p
e
d
delta
Current Snapshot to Disk
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
App and System Objects
Threads State
as Objects
.image
Current Snapshot to Disk
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
1.Discard
App and System Objects
Threads State
as Objects
.image
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
1.Discard 2. Save as
objects
App and System Objects
Threads State
as Objects
.image
Current Snapshot to Disk
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
1.Discard 2. Save as
objects
3. Promote
to old
App and System Objects
Threads State
as Objects
.image
Current Snapshot to Disk
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
1.Discard 2. Save as
objects
3. Promote
to old
4. Save to
Disk
App and System Objects
Threads State
as Objects
.image
Current Snapshot to Disk
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
1.Discard 2. Save as
objects
3. Promote
to old
4. Save to
Disk
Discards all optimisations:
slow shutdown => slow
startup
App and System Objects
Threads State
as Objects
.image
Current Snapshot to Disk
Goals
• Faster loading
• Faster snapshot
• Faster Multi-GB Heaps
• Load code
• Create Objects
• Run your app
• Maybe GC!
• Repeat
.image .image
Heap
Towards a Multi-file Snapshot Format
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
Direct Mapping
.image
• System memory mapping
• Minimize Swizzling
• Lazy loading of memory segments
Multiple Memory Segments
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
Direct Mapping
.image
• Independently and lazy loadable
• Independently storable
Old Objects’
Old Objects’
New Memory Segments
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
Direct Mapping
.image
• Reduced garbage collection pressure
• Great for opaque objects, and rarely changing objects
(code, literals…)
Perm Objects
Perm Objects
Semi-permanent Heap Segments
Heap
Separating Permanent Objects
• Permanent objects are roots
• But not all of them are roots
• We don’t want to iterate all permanent objects!
Maintaining a Remembered Set
• Get the real roots in a remembered set
• Updated with a write barrier and cleaned at GC
Semi-permanent Object Selection
Bad Semi-permanent Object Selection
Worst case: all permanent
are remembered (!!)
What objects should be permanent?
What objects should be permanent?
How to
minimise
remembered
objects?
Pitfalls of Semi-permanent Object Selection
• The remembered set can explode easily. E.g.,
• Objects that reference nil, true, false are always remembered
• If you make a class permanent
• => you probably want to make its method dictionary too
• => and its methods, and literals
• => and …
Potential: GC cut by half
• For production Apps!
• Some Heuristics:
• Code (+related) is semi-permanent
• Collections go with their inner array
• Association values are not (!!)
Relative Speedups
Automatic Object Selection via Simulations
• Estimate
• permanent segment size
• remembered set size
• Understand the leaking reasons
• And extract better heuristics for production code
(e.g., better move all classes with all method dictionaries…)
Future Perspectives
• Sharing permanent immutable objects, copy on write
• Scaling multi-process applications
• Application-speci
fi
c permanent object selection
JIT
Machine Code
Thread
Stacks
New Objects Old Objects Perm Objects
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
JIT
Machine Code
Thread
Stacks
New Objects Old Objects
We are hiring!
• We have
• Engineer Positions
• Phd Positions
• Keywords: Compilers, Interpreters, Memory Management, Security
• Come talk to us!
42
Conclusion
• Multi-
fi
le snapshot format
• Permanent Objects and Selection
• 2x GC improvements
• Load code
• Create Objects
• Run your app
• Maybe GC!
• Repeat
.image .image
JIT
Machine Code
Thread
Stacks
New Objects Old Objects Perm Objects
Relative Speedups

More Related Content

What's hot

PharoJS: Pharo-Based TDD for Javascript Applications
PharoJS: Pharo-Based TDD for Javascript ApplicationsPharoJS: Pharo-Based TDD for Javascript Applications
PharoJS: Pharo-Based TDD for Javascript Applications
ESUG
 

What's hot (20)

Microdown
MicrodownMicrodown
Microdown
 
re:mobidyc the overview
re:mobidyc the overviewre:mobidyc the overview
re:mobidyc the overview
 
PharoJS: Pharo-Based TDD for Javascript Applications
PharoJS: Pharo-Based TDD for Javascript ApplicationsPharoJS: Pharo-Based TDD for Javascript Applications
PharoJS: Pharo-Based TDD for Javascript Applications
 
Online Machine Learning: introduction and examples
Online Machine Learning:  introduction and examplesOnline Machine Learning:  introduction and examples
Online Machine Learning: introduction and examples
 
Applications in Pharo
Applications in PharoApplications in Pharo
Applications in Pharo
 
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban LorenzanoPharo foreign function interface (FFI) by example by Esteban Lorenzano
Pharo foreign function interface (FFI) by example by Esteban Lorenzano
 
The Principles of product development flow - a summary
The Principles of product development flow - a summary The Principles of product development flow - a summary
The Principles of product development flow - a summary
 
Story Mapping v4
Story Mapping v4Story Mapping v4
Story Mapping v4
 
Introductions to Online Machine Learning Algorithms
Introductions to Online Machine Learning AlgorithmsIntroductions to Online Machine Learning Algorithms
Introductions to Online Machine Learning Algorithms
 
Pairwise testing
Pairwise testingPairwise testing
Pairwise testing
 
Deep sarsa, Deep Q-learning, DQN
Deep sarsa, Deep Q-learning, DQNDeep sarsa, Deep Q-learning, DQN
Deep sarsa, Deep Q-learning, DQN
 
Intro to Object Detection with SSD
Intro to Object Detection with SSDIntro to Object Detection with SSD
Intro to Object Detection with SSD
 
Neural network pruning with residual connections and limited-data review [cdm]
Neural network pruning with residual connections and limited-data review [cdm]Neural network pruning with residual connections and limited-data review [cdm]
Neural network pruning with residual connections and limited-data review [cdm]
 
Agile Patterns and Anti-Patterns
Agile Patterns and Anti-PatternsAgile Patterns and Anti-Patterns
Agile Patterns and Anti-Patterns
 
Pillars of Scrum Slides for Andy
Pillars of Scrum Slides for AndyPillars of Scrum Slides for Andy
Pillars of Scrum Slides for Andy
 
Types of test tools
Types of test toolsTypes of test tools
Types of test tools
 
Zio in real world
Zio in real worldZio in real world
Zio in real world
 
Focal loss for dense object detection
Focal loss for dense object detectionFocal loss for dense object detection
Focal loss for dense object detection
 
C2 ae open set recognition
C2 ae open set recognitionC2 ae open set recognition
C2 ae open set recognition
 
使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)使用 Pytest 進行單元測試 (PyCon TW 2021)
使用 Pytest 進行單元測試 (PyCon TW 2021)
 

Similar to Improving Pharo Snapshots

How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
Mike Harris
 
Unbreaking Your Django Application
Unbreaking Your Django ApplicationUnbreaking Your Django Application
Unbreaking Your Django Application
OSCON Byrum
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
Mike Harris
 
rsec2a-2016-jheaton-morning
rsec2a-2016-jheaton-morningrsec2a-2016-jheaton-morning
rsec2a-2016-jheaton-morning
Jeff Heaton
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator Program
GoDataDriven
 

Similar to Improving Pharo Snapshots (20)

Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Object Oriented Paradigm
Object Oriented ParadigmObject Oriented Paradigm
Object Oriented Paradigm
 
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
How I Learned to Stop Worrying and Love Legacy Code - Ox:Agile 2018
 
Introduction to c ++ part -1
Introduction to c ++   part -1Introduction to c ++   part -1
Introduction to c ++ part -1
 
Unbreaking Your Django Application
Unbreaking Your Django ApplicationUnbreaking Your Django Application
Unbreaking Your Django Application
 
CPP02 - The Structure of a Program
CPP02 - The Structure of a ProgramCPP02 - The Structure of a Program
CPP02 - The Structure of a Program
 
CPP13 - Object Orientation
CPP13 - Object OrientationCPP13 - Object Orientation
CPP13 - Object Orientation
 
How to interactively visualise and explore a billion objects (wit vaex)
How to interactively visualise and explore a billion objects (wit vaex)How to interactively visualise and explore a billion objects (wit vaex)
How to interactively visualise and explore a billion objects (wit vaex)
 
Vaex talk-pydata-paris
Vaex talk-pydata-parisVaex talk-pydata-paris
Vaex talk-pydata-paris
 
Object Oriented Programming in Swift Ch0 - Encapsulation
Object Oriented Programming in Swift Ch0 - EncapsulationObject Oriented Programming in Swift Ch0 - Encapsulation
Object Oriented Programming in Swift Ch0 - Encapsulation
 
onGameStart
onGameStartonGameStart
onGameStart
 
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
GDC 2010 - A Dynamic Component Architecture for High Performance Gameplay - M...
 
Deep learning introduction
Deep learning introductionDeep learning introduction
Deep learning introduction
 
Embracing a Taxonomy of Types to Simplify Machine Learning with Leah McGuire
Embracing a Taxonomy of Types to Simplify Machine Learning with Leah McGuireEmbracing a Taxonomy of Types to Simplify Machine Learning with Leah McGuire
Embracing a Taxonomy of Types to Simplify Machine Learning with Leah McGuire
 
Alternative Approach to Plone Theming
Alternative Approach to Plone ThemingAlternative Approach to Plone Theming
Alternative Approach to Plone Theming
 
How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....How I Learned to Stop Worrying and Love Legacy Code.....
How I Learned to Stop Worrying and Love Legacy Code.....
 
.NET UY Meetup 7 - CLR Memory by Fabian Alves
.NET UY Meetup 7 - CLR Memory by Fabian Alves.NET UY Meetup 7 - CLR Memory by Fabian Alves
.NET UY Meetup 7 - CLR Memory by Fabian Alves
 
rsec2a-2016-jheaton-morning
rsec2a-2016-jheaton-morningrsec2a-2016-jheaton-morning
rsec2a-2016-jheaton-morning
 
Data Science Accelerator Program
Data Science Accelerator ProgramData Science Accelerator Program
Data Science Accelerator Program
 
Managing Memory in Swift (Yes, that's a thing)
Managing Memory in Swift (Yes, that's a thing)Managing Memory in Swift (Yes, that's a thing)
Managing Memory in Swift (Yes, that's a thing)
 

More from ESUG

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
ESUG
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
ESUG
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
ESUG
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
ESUG
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
ESUG
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
ESUG
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
ESUG
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
ESUG
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
ESUG
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
ESUG
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
ESUG
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
ESUG
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
ESUG
 

More from ESUG (20)

Workshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programmingWorkshop: Identifying concept inventories in agile programming
Workshop: Identifying concept inventories in agile programming
 
Technical documentation support in Pharo
Technical documentation support in PharoTechnical documentation support in Pharo
Technical documentation support in Pharo
 
The Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and RoadmapThe Pharo Debugger and Debugging tools: Advances and Roadmap
The Pharo Debugger and Debugging tools: Advances and Roadmap
 
Sequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in PharoSequence: Pipeline modelling in Pharo
Sequence: Pipeline modelling in Pharo
 
Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...Migration process from monolithic to micro frontend architecture in mobile ap...
Migration process from monolithic to micro frontend architecture in mobile ap...
 
Analyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early resultsAnalyzing Dart Language with Pharo: Report and early results
Analyzing Dart Language with Pharo: Report and early results
 
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
Transpiling Pharo Classes to JS ECMAScript 5 versus ECMAScript 6
 
A Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test GenerationA Unit Test Metamodel for Test Generation
A Unit Test Metamodel for Test Generation
 
Creating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic ProgrammingCreating Unit Tests Using Genetic Programming
Creating Unit Tests Using Genetic Programming
 
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution ModesThreaded-Execution and CPS Provide Smooth Switching Between Execution Modes
Threaded-Execution and CPS Provide Smooth Switching Between Execution Modes
 
Exploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience ReportExploring GitHub Actions through EGAD: An Experience Report
Exploring GitHub Actions through EGAD: An Experience Report
 
Pharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIsPharo: a reflective language A first systematic analysis of reflective APIs
Pharo: a reflective language A first systematic analysis of reflective APIs
 
Garbage Collector Tuning
Garbage Collector TuningGarbage Collector Tuning
Garbage Collector Tuning
 
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame CaseImproving Performance Through Object Lifetime Profiling: the DataFrame Case
Improving Performance Through Object Lifetime Profiling: the DataFrame Case
 
Pharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and FuturePharo DataFrame: Past, Present, and Future
Pharo DataFrame: Past, Present, and Future
 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
 
Websockets for Fencing Score
Websockets for Fencing ScoreWebsockets for Fencing Score
Websockets for Fencing Score
 
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScriptShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
ShowUs: PharoJS.org Develop in Pharo, Run on JavaScript
 
Advanced Object- Oriented Design Mooc
Advanced Object- Oriented Design MoocAdvanced Object- Oriented Design Mooc
Advanced Object- Oriented Design Mooc
 
A New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and TransformationsA New Architecture Reconciling Refactorings and Transformations
A New Architecture Reconciling Refactorings and Transformations
 

Recently uploaded

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 

Recently uploaded (20)

AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 
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
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
Facemoji Keyboard released its 2023 State of Emoji report, outlining the most...
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
Into the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdfInto the Box 2024 - Keynote Day 2 Slides.pdf
Into the Box 2024 - Keynote Day 2 Slides.pdf
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 

Improving Pharo Snapshots

  • 1. Improving Pharo Snapshots P. Tesone - G. Polito - N. Palumbo - ESUG’22 @tesonep @guillep @noTwitter guillermo.polito@univ-lille.fr pablo.tesone@inria.fr nahuel.palumbo@inria.fr
  • 3. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  • 4. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  • 5. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  • 6. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  • 7. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Everythingis an Object
  • 8. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Lots of Objects
  • 9. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Lots of Objects Lots of Stress
  • 10. • GC Stress • Autocompletion Stress • Search Stress • Spotter Stress • Startup Stress Lots of Objects Lots of Stress
  • 11. Large Image Support • https://github.com/pharo-project/largeImages • MIT Licenced
  • 12. Large Image Support: Highlights • Generator based searches • Spotter • Code Completion • GC Fine Tuning API generator ^ generator ifNil: [ generator := Generator on: [ :g | self entriesDo: [ :entry | (self acceptsEntry: entry) ifTrue: [ g yield: entry ] ] ] ]
  • 13. GC Fine Tuning • Con fi gure • Eden Size • Full GC Ratio • Growth Headroom • Shrink Threshold GCConfiguration readFromVM fullGCRatio: 1.0; activeDuring: [ “something" ].
  • 14. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Lots of Objects
  • 15. • Numbers • Characters • Strings • Arrays • Closures • Classes • Methods • … Images = Heap Snapshots .image save load Heap
  • 16. Snapshot Current Design Points • Bootstrap once, then mutate • Portable • Object References are pointers • Load code • Create Objects • Run your app • Maybe GC! • Repeat .image .image Heap
  • 17. But it could be better… • VM startup is bound by disk! • Large heaps take long to load/save • 3-4GB heaps = seconds to GC • pauses • long pauses • Load code • Create Objects • Run your app • Maybe GC! • Repeat .image .image Heap
  • 18. Snapshots vs Runtime Memory Mismatch App and System Objects Threads State as Objects JIT Machine Code Thread Stacks New Objects Old Objects .image
  • 19. Current Loading Snapshot to Memory JIT Machine Code Thread Stacks New Objects Old Objects Direct Mapping Rebuild Empty Empty .image App and System Objects Threads State as Objects Start with a cold VM, startup is slow
  • 20. Reference Swizzling • Traverse the heap to remap old references by delta • Slow for large heaps (2/4GB) Hot Methods Machine Code Process 1 Thread Stacks New Objects Old Objects Hot Methods Machine Code Process 2 Thread Stacks New Objects Old Objects R e m a p p e d delta
  • 21. Current Snapshot to Disk JIT Machine Code Thread Stacks New Objects Old Objects App and System Objects Threads State as Objects .image
  • 22. Current Snapshot to Disk JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard App and System Objects Threads State as Objects .image
  • 23. JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard 2. Save as objects App and System Objects Threads State as Objects .image Current Snapshot to Disk
  • 24. JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard 2. Save as objects 3. Promote to old App and System Objects Threads State as Objects .image Current Snapshot to Disk
  • 25. JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard 2. Save as objects 3. Promote to old 4. Save to Disk App and System Objects Threads State as Objects .image Current Snapshot to Disk
  • 26. JIT Machine Code Thread Stacks New Objects Old Objects 1.Discard 2. Save as objects 3. Promote to old 4. Save to Disk Discards all optimisations: slow shutdown => slow startup App and System Objects Threads State as Objects .image Current Snapshot to Disk
  • 27. Goals • Faster loading • Faster snapshot • Faster Multi-GB Heaps • Load code • Create Objects • Run your app • Maybe GC! • Repeat .image .image Heap
  • 28. Towards a Multi-file Snapshot Format JIT Machine Code Thread Stacks New Objects Old Objects JIT Machine Code Thread Stacks New Objects Old Objects Direct Mapping .image • System memory mapping • Minimize Swizzling • Lazy loading of memory segments
  • 29. Multiple Memory Segments JIT Machine Code Thread Stacks New Objects Old Objects JIT Machine Code Thread Stacks New Objects Old Objects Direct Mapping .image • Independently and lazy loadable • Independently storable Old Objects’ Old Objects’
  • 30. New Memory Segments JIT Machine Code Thread Stacks New Objects Old Objects JIT Machine Code Thread Stacks New Objects Old Objects Direct Mapping .image • Reduced garbage collection pressure • Great for opaque objects, and rarely changing objects (code, literals…) Perm Objects Perm Objects
  • 32. Separating Permanent Objects • Permanent objects are roots • But not all of them are roots • We don’t want to iterate all permanent objects!
  • 33. Maintaining a Remembered Set • Get the real roots in a remembered set • Updated with a write barrier and cleaned at GC
  • 35. Bad Semi-permanent Object Selection Worst case: all permanent are remembered (!!)
  • 36. What objects should be permanent?
  • 37. What objects should be permanent? How to minimise remembered objects?
  • 38. Pitfalls of Semi-permanent Object Selection • The remembered set can explode easily. E.g., • Objects that reference nil, true, false are always remembered • If you make a class permanent • => you probably want to make its method dictionary too • => and its methods, and literals • => and …
  • 39. Potential: GC cut by half • For production Apps! • Some Heuristics: • Code (+related) is semi-permanent • Collections go with their inner array • Association values are not (!!) Relative Speedups
  • 40. Automatic Object Selection via Simulations • Estimate • permanent segment size • remembered set size • Understand the leaking reasons • And extract better heuristics for production code (e.g., better move all classes with all method dictionaries…)
  • 41. Future Perspectives • Sharing permanent immutable objects, copy on write • Scaling multi-process applications • Application-speci fi c permanent object selection JIT Machine Code Thread Stacks New Objects Old Objects Perm Objects JIT Machine Code Thread Stacks New Objects Old Objects JIT Machine Code Thread Stacks New Objects Old Objects
  • 42. We are hiring! • We have • Engineer Positions • Phd Positions • Keywords: Compilers, Interpreters, Memory Management, Security • Come talk to us! 42
  • 43. Conclusion • Multi- fi le snapshot format • Permanent Objects and Selection • 2x GC improvements • Load code • Create Objects • Run your app • Maybe GC! • Repeat .image .image JIT Machine Code Thread Stacks New Objects Old Objects Perm Objects Relative Speedups