HeadlinesBriefing favicon HeadlinesBriefing.com

How Bootsnap Speeds Up Ruby CI Builds by 20 Minutes

Hacker News •
×

A developer at Intercom recently tackled a critical performance bottleneck in their CI pipeline by optimizing Ruby's path methods. With 1,350 parallel workers running by default, even shaving one second from setup time saves over 20 minutes of compute per build. The challenge stems from Ruby's expensive linear search through load paths when requiring files, which becomes increasingly costly as applications grow.

Bootsnap, now a default Rails gem, addresses this by caching load paths to eliminate repeated file system checks. Instead of scanning directories for each require call, Bootsnap builds a hash map of all potentially requirable files, allowing O(1) lookups instead of Ruby's O(N*M) search. This optimization becomes crucial when applications have hundreds of gems, as boot times scale poorly with gem count.

The developer discovered that on Intercom's monorepo, scanning all load paths took nearly a second - significant when multiplied across 1,350 workers. While Bootsnap's cache invalidation strategy uses directory modification times to detect changes, this approach has limitations on CI systems where git checkouts don't preserve timestamps. The team's focus on reducing setup time demonstrates how infrastructure optimization can deliver outsized returns compared to optimizing individual tests, especially in large-scale CI environments.