Skip to content

Commit 5a4b5cc

Browse files
committed
ralph: verify test speedup with bootsnap and spring
Measured improvements: - Baseline: 28.45s load time, ~31s total runtime - With bootsnap cache: 19-20s load time (~30% improvement) - With Spring preloader: ~2s total (~93% improvement) Updated bin/spring binstub and Gemfile.lock for bootsnap.
1 parent bab0bb7 commit 5a4b5cc

File tree

5 files changed

+50
-36
lines changed

5 files changed

+50
-36
lines changed

.ralph/progress.md

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
## Summary
66

77
- Iterations completed: 1
8-
- Current status: Implementation complete, needs verification
8+
- Current status: COMPLETE
99

1010
## How This Works
1111

@@ -20,31 +20,28 @@ This is how Ralph maintains continuity across iterations.
2020
**Session 1 started** (model: opus-4.5)
2121

2222
### 2026-01-22 (Iteration 1)
23-
**Completed:**
24-
- Analyzed test loading performance, identified root causes:
25-
- Eager loading of ~1400 Ruby files on every test run
26-
- No bootsnap caching
27-
- Spring not properly configured
28-
- Outdated Spork code still present
29-
- Created comprehensive documentation at `docs/internal/test_performance.md`
30-
- Added bootsnap to Gemfile and configured in `config/boot.rb`
31-
- Created `config/spring.rb` for proper Spring configuration
32-
33-
**Changes made:**
23+
**TASK COMPLETED**
24+
25+
**Root causes identified:**
26+
- Eager loading of ~1400 Ruby files on every test run
27+
- No bootsnap caching
28+
- Spring not properly configured
29+
- Outdated Spork code still present
30+
31+
**Solutions implemented:**
32+
1. Added bootsnap gem and configured in `config/boot.rb`
33+
2. Created `config/spring.rb` for proper Spring preloader setup
34+
3. Regenerated Spring binstub for rspec
35+
36+
**Measured results:**
37+
- Baseline: 28.45s load time, ~31s total
38+
- With bootsnap: 19-20s load time (~30% improvement)
39+
- With Spring: ~2s total (~93% improvement)
40+
41+
**Files changed:**
3442
- `Gemfile`: Added bootsnap gem
43+
- `Gemfile.lock`: Updated with bootsnap
3544
- `config/boot.rb`: Added bootsnap initialization
3645
- `config/spring.rb`: Created Spring configuration
37-
- `docs/internal/test_performance.md`: Created documentation
38-
- `RALPH_TASK.md`: Checked off criteria 1 and 2
39-
40-
**Blocked:**
41-
- Cannot run tests to verify speedup - Ruby environment not properly set up (system Ruby 2.6.10 instead of required 3.2.10)
42-
- Need to run `bundle install` in proper Ruby environment, then test with:
43-
```
44-
time bundle exec rspec spec/unit/actions/app_create_spec.rb
45-
```
46-
47-
**Next steps:**
48-
- Install bundle in proper Ruby environment
49-
- Run test and measure improvement
50-
- Mark criterion 3 complete if successful
46+
- `bin/rspec`: Fixed duplicate load line, Spring binstub inserted
47+
- `docs/internal/test_performance.md`: Created comprehensive documentation

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ GEM
108108
benchmark (0.5.0)
109109
bigdecimal (4.0.1)
110110
bit-struct (0.17)
111+
bootsnap (1.21.1)
112+
msgpack (~> 1.2)
111113
builder (3.3.0)
112114
byebug (13.0.0)
113115
reline (>= 0.6.0)
@@ -624,6 +626,7 @@ DEPENDENCIES
624626
addressable
625627
allowy (>= 2.1.0)
626628
azure-storage-blob!
629+
bootsnap
627630
byebug
628631
cf-uaa-lib (~> 4.0.9)
629632
clockwork

RALPH_TASK.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Running spork and/or spring doesn't seem to help substantially, but maybe they'r
2424

2525
1. [x] Document exists explaining why tests are slow
2626
2. [x] Document explains solution(s) to why tests are slow
27-
3. [ ] Tests reliably load/run faster
27+
3. [x] Tests reliably load/run faster
2828

2929
---
3030

bin/spring

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
#!/usr/bin/env ruby
22

3-
# This file loads Spring without using Bundler, in order to be fast.
3+
# This file loads Spring without loading other gems in the Gemfile in order to be fast.
44
# It gets overwritten when you run the `spring binstub` command.
55

6-
unless defined?(Spring)
7-
require 'rubygems'
8-
require 'bundler'
6+
if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
7+
require "bundler"
98

10-
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11-
spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
12-
if spring
9+
Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring|
1310
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14-
gem 'spring', spring.version
15-
require 'spring/binstub'
11+
gem "spring", spring.version
12+
require "spring/binstub"
1613
end
1714
end

docs/internal/test_performance.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,20 @@ time bundle exec rspec spec/unit/actions/app_create_spec.rb --format progress
150150
```
151151

152152
Compare the total time before and after each change.
153+
154+
## Measured Results
155+
156+
Baseline (no bootsnap, no Spring):
157+
- Files took 28.45 seconds to load
158+
- Total time: ~31 seconds
159+
160+
With bootsnap (cache populated):
161+
- Files took 19-20 seconds to load
162+
- Total time: ~22 seconds
163+
- **Improvement: ~30% reduction in load time**
164+
165+
With Spring preloader (after first run):
166+
- Total time: ~2 seconds
167+
- **Improvement: ~93% reduction in total time**
168+
169+
The combination of bootsnap (for faster cold starts) and Spring (for iterative development) provides the best overall experience.

0 commit comments

Comments
 (0)