Skip to content

Reduce install command load time - #23560

Merged
MikeMcQuaid merged 1 commit into
mainfrom
reduce-install-command-load
Aug 19, 2026
Merged

Reduce install command load time#23560
MikeMcQuaid merged 1 commit into
mainfrom
reduce-install-command-load

Conversation

@MikeMcQuaid

Copy link
Copy Markdown
Member
  • 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.
  • Cut warm no-op command_load from 96.96ms to 53.95ms on this base.

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

GPT 5.6 Sol xhigh with local review and testing.


Copilot AI lite review requested due to automatic review settings August 19, 2026 07:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 lightweight Library/Homebrew/install/check.rb and updated call sites to require it early.
  • Introduced Library/Homebrew/cask/cask_base.rb and updated livecheck.rb to depend on the lightweight base instead of requiring the full cask implementation.
  • Deferred heavyweight requires in cmd/install.rb, cli/named_args.rb, and cleanup.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.

Comment thread Library/Homebrew/test/cmd/install_spec.rb
Comment thread Library/Homebrew/cli/named_args.rb Outdated
Comment thread Library/Homebrew/cli/named_args.rb Outdated
@MikeMcQuaid
MikeMcQuaid force-pushed the reduce-install-command-load branch from 24c5271 to 87f12c8 Compare August 19, 2026 13:49
- 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
MikeMcQuaid force-pushed the reduce-install-command-load branch from 87f12c8 to ea94171 Compare August 19, 2026 14:22
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Aug 19, 2026
Merged via the queue into main with commit ad5738c Aug 19, 2026
46 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the reduce-install-command-load branch August 19, 2026 15:32
@capruxel capruxel mentioned this pull request Aug 22, 2026
8 tasks
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.

4 participants