# Optimizing Ruby Lazy Initialization in TruffleRuby with Deoptimization

DevFeed: [Optimizing Ruby Lazy Initialization in TruffleRuby with Deoptimization](<https://devfeed.tech/articles/optimizing-ruby-lazy-initialization-in-truffleruby-with-deoptimization-1511.md>)

Original publisher: [Read original article](<https://shopify.engineering/optimizing-ruby-lazy-initialization-in-truffleruby-with-deoptimization>)

Author: Carol Chen

Published: 2020-03-31T14:30:00Z

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>), [Benchmark](<https://devfeed.tech/topics/benchmark.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>), [Open Source](<https://devfeed.tech/topics/open-source.md>)

Tags: [benchmark](<https://devfeed.tech/tags/benchmark.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [performance](<https://devfeed.tech/tags/performance.md>), [profiling](<https://devfeed.tech/tags/profiling.md>), [ruby](<https://devfeed.tech/tags/ruby.md>)

## AI overview

Shopify engineers investigate optimizing Ruby's idiomatic lazy initialization pattern in TruffleRuby, an alternative Ruby implementation developed by Oracle Labs. The article describes profiling the ||= operator across 20 open-source projects and prioritizing compiler behavior that can reduce emitted machine code and improve performance.

## Source excerpt

Shopify's involvement with TruffleRuby began half a year ago, with the goal of furthering the success of the project and Ruby community. TruffleRuby is an alternative implementation of the Ruby language (where the reference implementation is CRuby, or MRI) developed by Oracle Labs. TruffleRuby has high potential in speed, as it is nine times faster than CRuby on optcarrot, a NES emulator benchmark developed by the Ruby Core Team.