Ruby App Boot Time Optimization
Bootsnap: Optimizing Ruby App Boot Time - Shopify

Bootsnap: Optimizing Ruby App Boot Time - Shopify

5/18/2017

What this post added

This post introduces Bootsnap, a gem that optimizes Ruby application boot time by implementing two main strategies: path pre-scanning and compilation caching. Path pre-scanning optimizes `Kernel#require` and `ActiveSupport` autoloads by caching `$LOAD_PATH` scans and `ActiveSupport::Dependencies.autoload_paths` scans, reducing filesystem accesses. Compilation caching leverages `RubyVM::InstructionSequence.load_iseq` to cache Ruby bytecode compilation results and `YAML.load_file` to cache YAML deserialization into MessagePack format, bypassing expensive compilation and parsing steps on subsequent loads. The post details the technical implementation of these caching mechanisms, including cache invalidation strategies and the use of extended file attributes (xattrs) for storing compiled bytecode. It also presents performance results showing significant boot time reductions for various application sizes.

Read the original post ↗