Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
RubyConf 2019 - Compacting Heaps in Ruby 2.7 by Aaron Patterson Ruby 2.7 will feature a manual heap compactor integrated with the GC. In this presentation we'll cover how Ruby's memory is arranged, how compaction can be helpful to your application, as well as algorithms and implementation details of the heap compactor. As a bonus, we'll cover GC debugging techniques as well! This presentation is going to be heaps of fun. Don't turn the page because we're going to scan the stack for some great pointers! #confreaks #rubyconf2019
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In this video from RubyConf 2019, Aaron Patterson presents the topic of manual heap compaction in Ruby 2.7, discussing its integration with the garbage collector (GC). The presentation covers important concepts of Ruby's memory management, the necessity and benefits of heap compaction, and the algorithms behind this implementation. As Patterson explains, compaction is intended to rearrange allocated and free memory for improved efficiency, similar to defragmenting a hard drive. The motivations for implementing compaction are outlined as follows: - **Efficient Memory Usage**: By compacting memory, fragmentation issues are reduced, allowing for the allocation of new chunks of memory without the drawbacks of intertwined free and allocated spaces. - **Improved CPU Cache Utilization**: Keeping related data together optimizes data retrieval through the CPU cache, reducing the need for slower accesses to the RAM. - **Copy-on-Write Friendliness**: Compaction makes memory usage more effective by reducing overhead in processes like those used in web servers where memory sharing is crucial. Patterson explains the two types of heaps managed in Ruby: the malloc heap and Ruby’s object heap, focusing primarily on how fragmentation occurs in the object heap. He presents a new algorithm – the **2-finger compaction algorithm**, which uses two pointers that operate to rearrange memory, leading to more contiguous free spaces. Challenges encountered include the complexity of updating references during the garbage collection process, particularly with the involvement of C extensions that require careful management to avoid crashes. Patterson emphasizes that about 80% of the implementation patch was devoted to reference updates, a task made challenging by the need for careful handling of object identifiers. Switching from memory address-based IDs to unique identifiers significantly minimized issues during compaction. In conclusion, Patterson shares that the new heap compactor decreased heap size by approximately 10%, showcasing the efficiency improvements achieved through this process. Looking to the future, he hints at plans for automatic compaction in Ruby 3.0, aiming to enhance performance and memory efficiency further. With this insightful presentation, Patterson highlights the continuous advancement of Ruby through dedicated efforts from the Ruby Core team.
Suggest modifications
Cancel