Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formulae_dependents: apply some optimisations #841

Closed
wants to merge 1 commit into from

Commits on Sep 26, 2022

  1. formulae_dependents: apply some optimisations

    1. Doing `brew install --only-dependencies` and `brew postinstall` can
       be quite expensive. Let's defer this to when we're sure we have
       dependents to test.
    2. Calling `brew uses` is slow, because this requires traversing the
       dependency tree. [*] Let's avoid doing this unless we know we really
       need to. Here, we test for "needing to" by checking if another `.rb`
       file in the tap that might be a formula contains a `depends_on` line
       declaring a dependency on the formula being tested.
    3. Restrict the second `brew uses` call to when we are building
       dependents from source, since that is the only instance where we are
       interested in the build dependents.
    
    While we're here, make sure to call `brew postinstall` on all
    dependencies that were rebuilt, and not just the one being tested
    currently. This may address Homebrew#805.
    
    Locally, this results in the following speed up for a formula with no
    dependents:
    
    Before
    
        ( brew test-bot --only-formulae-dependents --testing-formulae=hello --dry-run)  28.95s user 6.70s system 76% cpu 46.875 total
    
    After
    
        ( brew test-bot --only-formulae-dependents --testing-formulae=hello --dry-run)  0.91s user 1.02s system 51% cpu 3.738 total
    
    This makes testing formulae with dependents slightly slower. However,
    the vast majority of formulae in Homebrew/core have no dependents (on
    macOS, at least), so this is likely a net win for the average workflow.
    
    [*] Potential future optimisation: calling `Dependency.expand` directly
        might give us better opportunities to exploit caching.
    carlocab committed Sep 26, 2022
    Configuration menu
    Copy the full SHA
    507686e View commit details
    Browse the repository at this point in the history