Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Have you ever wondered how class variables (CVARs) in Ruby work? Would you be surprised to learn that their performance becomes increasingly worse as the inheritance chain grows? I’m excited to share that in Ruby 3.1 we fixed the performance of CVARs. In this talk we'll look at the language design of class variables, learn about how they work, and, deep dive into how we improved their performance in Ruby 3.1 by adding a cache! We'll look at the cache design and real-world benchmarks showing how much faster they are regardless of the size of the inheritance chain.
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
The video presents a talk by Eileen Uchitelle at RubyConf 2021, focusing on the performance improvements of class variables (CVARs) in Ruby 3.1. The discussion explores the complexities of how CVARs operate, particularly in terms of inheritance. Key points include: - **Understanding Class Variables**: CVARs are defined at the class level, indicated by two '@' signs, and have distinct behaviors when it comes to inheritance compared to instance variables. They are shared across class descendants, which can lead to unexpected results when setting them in subclasses. - **Performance Issues**: The complexity in CVAR inheritance causes significant performance slowdowns, especially as the inheritance chain deepens. Benchmarks indicated that accessing CVARs could be much slower with deep inheritance. - **Introducing a Cache**: Uchitelle and Aaron Patterson developed a caching mechanism that minimizes the performance hit caused by CVAR reads and writes. This cache helps reduce the frequency of walking the entire inheritance chain to access class variables, thus improving performance. - **Real-World Impact**: Their improvements resulted in a six to seven percent increase in request handling in Rails applications, demonstrating that the caching solution offers substantial benefits in practical scenarios. - **Concerns and Negotiations with the Ruby Core Team**: Uchitelle discussed the skepticism faced from Ruby's maintainers regarding increased complexity and potential overuse of class variables due to performance enhancements. They emphasized the importance of understanding trade-offs in open-source contributions while effectively advocating for their changes. Ultimately, the cache was merged and rolled out to users with Ruby 3.1, highlighting the collaborative effort and negotiation skills required in open-source development. The talk concludes with a call to action for developers to contribute to Ruby, emphasizing that collective improvements can ensure Ruby's longevity and efficiency as a programming language.
Suggest modifications
Cancel