Reduce install command load time - #23560
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces brew install command load time by splitting lightweight install checks and the cask base class out of heavier require graphs, and by deferring full installer/cask implementation loads until the relevant code paths execute.
Changes:
- Extracted
Install.install_formula?into a new lightweightLibrary/Homebrew/install/check.rband updated call sites to require it early. - Introduced
Library/Homebrew/cask/cask_base.rband updatedlivecheck.rbto depend on the lightweight base instead of requiring the full cask implementation. - Deferred heavyweight
requires incmd/install.rb,cli/named_args.rb, andcleanup.rb, and added a spec to assert deferred loading at command load time.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| Library/Homebrew/test/cmd/install_spec.rb | Adds a command-load regression test for deferred requires; updates test requires accordingly. |
| Library/Homebrew/livecheck.rb | Uses cask/cask_base to avoid pulling in the full cask graph at load time. |
| Library/Homebrew/install/check.rb | New lightweight module containing Install.install_formula? pre-install checks. |
| Library/Homebrew/install.rb | Requires install/check and removes the inlined install_formula? implementation. |
| Library/Homebrew/cmd/install.rb | Defers heavy requires (install, cask installer/upgrade, attestation, missing_formula) to runtime paths. |
| Library/Homebrew/cli/named_args.rb | Defers cask/cask_loader until actually needed for cask loading/conflict warnings. |
| Library/Homebrew/cleanup.rb | Defers cask/cask_loader until clean! execution. |
| Library/Homebrew/cask/cask.rb | Requires cask/cask_base and relies on it for Forwardable extension. |
| Library/Homebrew/cask/cask_base.rb | New minimal Cask::Cask base to support lightweight type references and later reopening. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
carlocab
approved these changes
Aug 19, 2026
carlocab
reviewed
Aug 19, 2026
MikeMcQuaid
force-pushed
the
reduce-install-command-load
branch
from
August 19, 2026 13:49
24c5271 to
87f12c8
Compare
- Split lightweight formula checks and the base cask class from their larger implementation graphs. - Load full formula and cask installers only when their paths are used. - Keep deferred consumers explicit about their runtime dependencies. - Cut warm no-op `command_load` from 89.05ms to 51.11ms on this base. - Avoid loading 133 features and 79 cask paths during dispatch.
MikeMcQuaid
force-pushed
the
reduce-install-command-load
branch
from
August 19, 2026 14:22
87f12c8 to
ea94171
Compare
p-linnane
approved these changes
Aug 19, 2026
8 tasks
8 tasks
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
command_loadfrom 96.96ms to 53.95ms on this base.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?GPT 5.6 Sol xhigh with local review and testing.