Performance impact of the memoization idiom on modern Ruby | Rails at Scale
26-Oct-2023 796
Ruby 3.2 saw the introduction of object shapes which speedup instance variables access in most cases, but can be slower in some pathological casesOne major internal change in Ruby 3.2 was the introduction of object shapes.In this post, we’ll try to cover why they were introduced, how they work, and what their limitations are.How object instance variables are storedBecause of how dynamic Ruby is, an operation as simple as accessing an instance variable is a lot of work.In most cases, Ruby objects store their instance variables in an array of references.For instance, let’s create a simple object with 2 instance variables:.
Performance impact of the memoization idiom on modern Ruby | Rails at Scale #ruby #rubydeveloper #rubyonrails #Performance #impact #memoization #idiom #modern #Rails #Scale #performance https://rubyonrails.ba/link/performance-impact-of-the-memoization-idiom-on-modern-ruby-rails-at-scale