SlideShare une entreprise Scribd logo
1  sur  57
Télécharger pour lire hors ligne
Efficient support for
schema migration
Clément Béra - Smalltalks 2015
Myself
• Clément Béra
• 2 years virtual machine engineer in the
Pharo team
• Phd student for the past year
• JIT compiler
• Memory management
Paper
Eliot Miranda, Clément Béra,
A Partial Read Barrier for Efficient Support of
Live Object-oriented Programming,
International Symposium on Memory
Management 2015
Plan
• What is schema migration
• Existing implementations
• Spur’s partial read barrier
Schema Migration
Schema Migration
Schema Migration
• 1) Creation of a new class and new
subclasses
• 2) Creation of new instances
• 3) Migration of the instances
1. Class Creation
• Person has no subclasses
• Creation of the new class Person with two
instance variables
1I. Instances Creation
• A new instance of Person is created for each
existing instance
• New instances have an additional slot in
memory
III. Migration
• All the references to the old instances
now refers to the new instances
• How is that implemented ?
III. Migration (become)
• Conceptually, become exchanges the
references of two objects
• If a becomes b, all the references to a
now refer to b and all the references to b
now refer to a
III. Migration (become)
• Example with Colors
III. Migration (become)
• All the existing instances become the
new instances
Difficult Operation
• Any object in the heap can reference the
‘John’ object
• Different size: we can’t swap the object
contents
Existing Implementations
• Full heap scan
• Object Table
• Split Memory representation of objects
Full Heap Scan
• Implemented in
• Berkeley Smalltalk
• SelfVM
• CogVM
Memory Representation
new John header
name = 'John'
address = nil
chunks of memory
with unknown data
new version of
the John object
Heap portion
Implementation
• If a becomes b, scan all the heap and
patches all references
Full Heap Scan
new John header
name = 'John'
address = nil
old John header
name = 'John'
an Object
d field 1
pointer to
chunks of memory
with unknown data
new version of
the John object
old version of
the John object
Heap portion
Full Heap Scan
new John header
name = 'John'
address = nil
old John header
name = 'John'
an Object
d field 1
pointer to
chunks of memory
with unknown data
new version of
the John object
old version of
the John object
Heap portion
new John header
name = 'John'
address = nil
old John header
name = 'John'
an Object
d field 1
pointer to
chunks of memory
with unknown data
new version of
the John object
old version of
the John object
Heap portion
Pros And Cons
• Object in 1 chunk of memory with direct
pointers: faster field access
• Become performance is relative to the
heap size
Pros And Cons
CogVM
(before Spur)
Object Table
• Implemented in:
• Smalltalk-80
• Gemstone
Object Table
• Each reference to an object refers to an
entry in a table with all objects
Xerox Dorado Example
old John header
name = 'John'
an Object
d field 1
Heap portionObject table
object metadata object
address
0x0000143e
pointer to
chunks of memory
with unknown data
conceptual pointer
refCount gc type bank
10100101 101 1 1010
Implementation
• Become
• swaps 2 entries in the object table
Pros And Cons
• Very fast become
• Object table slows object reference
reads
• Extra indirection
Split Memory Representation
• Advanced version of the object table
• Implemented in ???
Split Memory Representation
• Advanced version of the object table
• Implemented in ???
• I heard a guy who knows a guy that
whispered once that it was
implemented like that inVW, but who
knows for sure?
Split Memory Representation
• The object is split in memory in 2 parts:
• fixed sized header with a pointer to its
fields
• fields
Split Memory Representation
John header
name = 'John'
pointer to
chunks of memory
with unknown data
John object
Heap portion
fields
Become
• Swap the fixed sized part of the object
Split Memory
new John header
name = 'John'
address = nil
old John header
name = 'John'
an Object
field 1
pointer to
chunks of memory
with unknown data
new version of
the John object
old version of
the John object
Heap portion
fields
fields
Split Memory
new John header
name = 'John'
address = nil
old John header
name = 'John'
an Object
field 1
pointer to
chunks of memory
with unknown data
new version of
the John object
old version of
the John object
Heap portion
fields
fields
old John header
name = 'John'
address = nil
new John header
name = 'John'
an Object
field 1
pointer to
chunks of memory
with unknown data
Heap portion
fields
fields
Pros And Cons
• Very fast become (~ 2 microseconds)
• Split memory representation slows field
access (extra far memory read)
Spur’s Partial Read Barrier
• We wanted none of the deficiencies
• Fast become independent to heap size
• Objects in 1 chunk of memory
• Direct pointers
Forwarding Objects
• Conceptually, when a reference to a
forwarding object is read, it is forwarded
to another object
Forwarding Objects
another Object
Forwarder
an Object
field 1
pointer to
chunks of memory
with unknown data
Heap portion
object
field 1
field 2
conceptual pointer
Forwarding Objects
• read barrier ???
Forwarding Objects
• Forwarding objects have special class and
special format
• Most operations requires a class or
format check
• send: receiver class check
• at: / at:put: format check
Send Example
• lookup cache (global or inline)
• receiver class + selector => method
• Caches refuse to enter forwarder class
• Cache hit implies receiver is not a
forwarder
Send example
• 97% of interpreted sends have global
cache hit
• 99% of machine code sends have inline
cache hit
• Needs to check for forwarders only on
cache miss
Forwarding Objects
• Similar idea for at: and at: put:
• The read barrier is effectively partial
Issue 1
• Each object requires at least 1 field
• Objects with 0 fields now requires 1 field
• Still less memory wasted than in a split
memory representation / object table
design
Issue 2
• Some operations have no class / format
check:
• Instance variable access
• method access
• Solution: receiver and method fields in stack
frames are not forwarders
• A new forwarder requires a stack zone scan
Become step 1/2
• step 1/2
• copy large object
• write small object into the large object
memory zone
• replace the small object by a forwarder
to the large object copy
old John header
name = 'John'
(unused) address
Forwarder
object
an Object
d field 1
pointer to
chunks of memory
with unknown data
Heap portion
new John header
name = 'John'
address = nil
conceptual pointer
Become step 1/2
new John header
name = 'John'
address = nil
old John header
name = 'John'
an Object
d field 1
pointer to
chunks of memory
with unknown data
new version of
the John object
old version of
the John object
Heap portion
Become step 2/2
• Stack zone scan
• Replace forwarder references for
receiver and method slots in frames
• Micro optimizations
Comparison
• Full heap scan
• Become last ~200 microseconds
• Independent to the heap size
• Objects are also in 1 chunk of memory
with direct pointers
Comparison (2)
• Object Table / Split Memory
representation
• Objects are in 1 chunk of memory and
direct pointers
• Become last ~200 microseconds
instead of ~2
• Become slower but Smalltalk
Conclusion
• Spur’s implementation have none of the
deficiencies:
• Fast become
• Objects in 1 chunk of memory
• In production for NewSpeak and Squeak
• Incoming for Pharo
Questions
Pypy’s
• In Python you can dynamically add
instance variable to instances
• Similar problem than become
Pypy’s
• Each object have exactly 5 fields in
memory + their header
• The last field is a reference to the rest of
the fields if the object is bigger than 5
Pypy’s
object header (2 inst
vars)
chunks of memory
with unknown data
Heap portion
field 1
field 2
(unused) field 3
(unused) field 4
(unused) extra fields
object header (6 inst
vars)
field 1
field 2
field 3
field 4
extra fields
pointer to
field 5
field 6
Become
• Swaps the headers and 5 fields contents
Discussion
• Missing comparison between Pypy’s style
scheme and the forwarder scheme

Contenu connexe

Dernier

Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsMehedi Hasan Shohan
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 

Dernier (20)

Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
XpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software SolutionsXpertSolvers: Your Partner in Building Innovative Software Solutions
XpertSolvers: Your Partner in Building Innovative Software Solutions
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 

En vedette

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
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

En vedette (20)

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...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

Efficient support for schema migration

  • 1. Efficient support for schema migration Clément Béra - Smalltalks 2015
  • 2. Myself • Clément Béra • 2 years virtual machine engineer in the Pharo team • Phd student for the past year • JIT compiler • Memory management
  • 3. Paper Eliot Miranda, Clément Béra, A Partial Read Barrier for Efficient Support of Live Object-oriented Programming, International Symposium on Memory Management 2015
  • 4. Plan • What is schema migration • Existing implementations • Spur’s partial read barrier
  • 7. Schema Migration • 1) Creation of a new class and new subclasses • 2) Creation of new instances • 3) Migration of the instances
  • 8. 1. Class Creation • Person has no subclasses • Creation of the new class Person with two instance variables
  • 9. 1I. Instances Creation • A new instance of Person is created for each existing instance • New instances have an additional slot in memory
  • 10. III. Migration • All the references to the old instances now refers to the new instances • How is that implemented ?
  • 11. III. Migration (become) • Conceptually, become exchanges the references of two objects • If a becomes b, all the references to a now refer to b and all the references to b now refer to a
  • 12. III. Migration (become) • Example with Colors
  • 13. III. Migration (become) • All the existing instances become the new instances
  • 14. Difficult Operation • Any object in the heap can reference the ‘John’ object • Different size: we can’t swap the object contents
  • 15. Existing Implementations • Full heap scan • Object Table • Split Memory representation of objects
  • 16. Full Heap Scan • Implemented in • Berkeley Smalltalk • SelfVM • CogVM
  • 17. Memory Representation new John header name = 'John' address = nil chunks of memory with unknown data new version of the John object Heap portion
  • 18. Implementation • If a becomes b, scan all the heap and patches all references
  • 19. Full Heap Scan new John header name = 'John' address = nil old John header name = 'John' an Object d field 1 pointer to chunks of memory with unknown data new version of the John object old version of the John object Heap portion
  • 20. Full Heap Scan new John header name = 'John' address = nil old John header name = 'John' an Object d field 1 pointer to chunks of memory with unknown data new version of the John object old version of the John object Heap portion new John header name = 'John' address = nil old John header name = 'John' an Object d field 1 pointer to chunks of memory with unknown data new version of the John object old version of the John object Heap portion
  • 21. Pros And Cons • Object in 1 chunk of memory with direct pointers: faster field access • Become performance is relative to the heap size
  • 23. Object Table • Implemented in: • Smalltalk-80 • Gemstone
  • 24. Object Table • Each reference to an object refers to an entry in a table with all objects
  • 25. Xerox Dorado Example old John header name = 'John' an Object d field 1 Heap portionObject table object metadata object address 0x0000143e pointer to chunks of memory with unknown data conceptual pointer refCount gc type bank 10100101 101 1 1010
  • 26. Implementation • Become • swaps 2 entries in the object table
  • 27. Pros And Cons • Very fast become • Object table slows object reference reads • Extra indirection
  • 28. Split Memory Representation • Advanced version of the object table • Implemented in ???
  • 29. Split Memory Representation • Advanced version of the object table • Implemented in ??? • I heard a guy who knows a guy that whispered once that it was implemented like that inVW, but who knows for sure?
  • 30. Split Memory Representation • The object is split in memory in 2 parts: • fixed sized header with a pointer to its fields • fields
  • 31. Split Memory Representation John header name = 'John' pointer to chunks of memory with unknown data John object Heap portion fields
  • 32. Become • Swap the fixed sized part of the object
  • 33. Split Memory new John header name = 'John' address = nil old John header name = 'John' an Object field 1 pointer to chunks of memory with unknown data new version of the John object old version of the John object Heap portion fields fields
  • 34. Split Memory new John header name = 'John' address = nil old John header name = 'John' an Object field 1 pointer to chunks of memory with unknown data new version of the John object old version of the John object Heap portion fields fields old John header name = 'John' address = nil new John header name = 'John' an Object field 1 pointer to chunks of memory with unknown data Heap portion fields fields
  • 35. Pros And Cons • Very fast become (~ 2 microseconds) • Split memory representation slows field access (extra far memory read)
  • 36. Spur’s Partial Read Barrier • We wanted none of the deficiencies • Fast become independent to heap size • Objects in 1 chunk of memory • Direct pointers
  • 37. Forwarding Objects • Conceptually, when a reference to a forwarding object is read, it is forwarded to another object
  • 38. Forwarding Objects another Object Forwarder an Object field 1 pointer to chunks of memory with unknown data Heap portion object field 1 field 2 conceptual pointer
  • 40. Forwarding Objects • Forwarding objects have special class and special format • Most operations requires a class or format check • send: receiver class check • at: / at:put: format check
  • 41. Send Example • lookup cache (global or inline) • receiver class + selector => method • Caches refuse to enter forwarder class • Cache hit implies receiver is not a forwarder
  • 42. Send example • 97% of interpreted sends have global cache hit • 99% of machine code sends have inline cache hit • Needs to check for forwarders only on cache miss
  • 43. Forwarding Objects • Similar idea for at: and at: put: • The read barrier is effectively partial
  • 44. Issue 1 • Each object requires at least 1 field • Objects with 0 fields now requires 1 field • Still less memory wasted than in a split memory representation / object table design
  • 45. Issue 2 • Some operations have no class / format check: • Instance variable access • method access • Solution: receiver and method fields in stack frames are not forwarders • A new forwarder requires a stack zone scan
  • 46. Become step 1/2 • step 1/2 • copy large object • write small object into the large object memory zone • replace the small object by a forwarder to the large object copy
  • 47. old John header name = 'John' (unused) address Forwarder object an Object d field 1 pointer to chunks of memory with unknown data Heap portion new John header name = 'John' address = nil conceptual pointer Become step 1/2 new John header name = 'John' address = nil old John header name = 'John' an Object d field 1 pointer to chunks of memory with unknown data new version of the John object old version of the John object Heap portion
  • 48. Become step 2/2 • Stack zone scan • Replace forwarder references for receiver and method slots in frames • Micro optimizations
  • 49. Comparison • Full heap scan • Become last ~200 microseconds • Independent to the heap size • Objects are also in 1 chunk of memory with direct pointers
  • 50. Comparison (2) • Object Table / Split Memory representation • Objects are in 1 chunk of memory and direct pointers • Become last ~200 microseconds instead of ~2 • Become slower but Smalltalk
  • 51. Conclusion • Spur’s implementation have none of the deficiencies: • Fast become • Objects in 1 chunk of memory • In production for NewSpeak and Squeak • Incoming for Pharo
  • 53. Pypy’s • In Python you can dynamically add instance variable to instances • Similar problem than become
  • 54. Pypy’s • Each object have exactly 5 fields in memory + their header • The last field is a reference to the rest of the fields if the object is bigger than 5
  • 55. Pypy’s object header (2 inst vars) chunks of memory with unknown data Heap portion field 1 field 2 (unused) field 3 (unused) field 4 (unused) extra fields object header (6 inst vars) field 1 field 2 field 3 field 4 extra fields pointer to field 5 field 6
  • 56. Become • Swaps the headers and 5 fields contents
  • 57. Discussion • Missing comparison between Pypy’s style scheme and the forwarder scheme