# Optimizing Ruby's Memory Layout: Variable Width Allocation

DevFeed: [Optimizing Ruby's Memory Layout: Variable Width Allocation](<https://devfeed.tech/articles/optimizing-ruby-s-memory-layout-variable-width-allocation-1557.md>)

Original publisher: [Read original article](<https://shopify.engineering/ruby-variable-width-allocation>)

Author: Peter Zhu

Published: 2022-12-25T05:01:01Z

Content type: article

Language: en

Sources: [Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering.md>), [Shopify Engineering - Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering-shopify-engineering.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [Shopify](<https://devfeed.tech/topics/shopify.md>), [systems](<https://devfeed.tech/topics/systems.md>), [Cache](<https://devfeed.tech/topics/cache.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [blog](<https://devfeed.tech/tags/blog.md>), [cache](<https://devfeed.tech/tags/cache.md>), [memory](<https://devfeed.tech/tags/memory.md>), [performance](<https://devfeed.tech/tags/performance.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [shopify](<https://devfeed.tech/tags/shopify.md>), [systems](<https://devfeed.tech/tags/systems.md>)

## AI overview

Shopify describes the Variable Width Allocation project, which improves CRuby performance in Ruby 3.2 by optimizing the garbage collector's memory layout. The article explains Ruby's fixed-size object slots, heap pages, allocation trade-offs, and limitations such as poor data locality caused by the interaction with CPU caches.

## Source excerpt

Shopify is improving CRuby's performance in Ruby 3.2 by optimizing the memory layout in the garbage collector through the Variable Width Allocation project.