Skip to content

Don't eager load the CLI - #826

Open
linyiru wants to merge 1 commit into
rails:mainfrom
linyiru:do-not-eager-load-cli
Open

linyiru wants to merge 1 commit into
rails:mainfrom
linyiru:do-not-eager-load-cli

Conversation

@linyiru

@linyiru linyiru commented Oct 31, 2026

Copy link
Copy Markdown

Zeitwerk eager loads lib/solid_queue/cli.rb, which requires Thor, so every process of an application that eager loads, like its Puma workers, loads Thor and the CLI. Only bin/jobs uses the CLI, and the generated bin/jobs requires solid_queue/cli itself.

This leaves cli.rb out of eager loading with do_not_eager_load. SolidQueue::Cli is still autoloaded when referenced.

Booting a new Rails application (rails new, Rails main, Solid Queue 1.7.0) in production with eager_load, Ruby 3.4.12 on Debian 13, 7 alternating runs:

before after
Boot, median 1114 ms 1106 ms
Files loaded 2301 2283
Objects allocated 710,791 707,150

The test boots the dummy app in a subprocess, eager loads, and checks SolidQueue::Cli is still an autoload. It fails without the change. bin/rails test passes with SQLite, with and without CI=1 (which turns on eager loading in the dummy app's test environment).

🤖 Generated with Claude Code

Eager loading lib/solid_queue/cli.rb loads Thor in every process of an
application that eager loads, like its web servers, although only
bin/jobs uses the CLI, and bin/jobs requires it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rosa
rosa force-pushed the do-not-eager-load-cli branch from 81f4a56 to b5d1484 Compare November 2, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant