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

completions: improve list of available services and outdated checks #16651

Merged
merged 1 commit into from
Feb 13, 2024
Merged

completions: improve list of available services and outdated checks #16651

merged 1 commit into from
Feb 13, 2024

Conversation

razvanazamfirei
Copy link
Member

@razvanazamfirei razvanazamfirei commented Feb 13, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This PR makes some improvements to the completions.

  1. It improves the logic for finding services
  2. It passes HOMEBREW_NO_AUTO_UPDATE=1 to all brew outdated calls in the completions. While this change prevents the completion from fetching outdated casks/formulas by itself, it represents a substantial improvement in a completion that is otherwise input-blocking.
❯ hyperfine "brew outdated --formula --verbose  | string replace -r '\s' '\t'" "HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula --verbose 2>/dev/null | string replace -r '\s' '\t'" --shell fish
Benchmark 1: brew outdated --formula --verbose  | string replace -r '\s' '\t'
  Time (mean ± σ):      3.686 s ±  0.879 s    [User: 0.845 s, System: 0.238 s]
  Range (min … max):    3.183 s …  6.048 s    10 runs

Benchmark 2: HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula --verbose 2>/dev/null | string replace -r '\s' '\t'
  Time (mean ± σ):      1.462 s ±  0.045 s    [User: 0.836 s, System: 0.223 s]
  Range (min … max):    1.399 s …  1.548 s    10 runs

Summary
  HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --formula --verbose 2>/dev/null | string replace -r '\s' '\t' ran
    3.52 ± 0.61 times faster than brew outdated --formula --verbose  | string replace -r '\s' '\t'
❯ hyperfine "brew outdated --cask --verbose 2>/dev/null | string replace -r '\s' '\t'" "HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask --verbose 2>/dev/null | string replace -r '\s' '\t'" --shell fish
Benchmark 1: brew outdated --cask --verbose 2>/dev/null | string replace -r '\s' '\t'
  Time (mean ± σ):      3.211 s ±  0.013 s    [User: 0.454 s, System: 0.140 s]
  Range (min … max):    3.190 s …  3.232 s    10 runs

Benchmark 2: HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask --verbose 2>/dev/null | string replace -r '\s' '\t'
  Time (mean ± σ):     886.5 ms ±  68.7 ms    [User: 433.1 ms, System: 125.2 ms]
  Range (min … max):   812.5 ms … 1018.8 ms    10 runs

Summary
  HOMEBREW_NO_AUTO_UPDATE=1 brew outdated --cask --verbose 2>/dev/null | string replace -r '\s' '\t' ran
    3.62 ± 0.28 times faster than brew outdated --cask --verbose 2>/dev/null | string replace -r '\s' '\t'
Benchmark 1:     command find (brew --cellar) -mindepth 3 -maxdepth 3 -name '*.service'       | awk -F'homebrew.|.service' '{print }'       | sort -d
  Time (mean ± σ):      59.2 ms ±   3.3 ms    [User: 8.4 ms, System: 43.4 ms]
  Range (min … max):    56.1 ms …  73.2 ms    27 runs

Benchmark 2:     set -l list (brew services list)
    set -e list[1] # Header
    for line in
        echo (string split ' ' )[1]
    end
  Time (mean ± σ):      1.687 s ±  0.097 s    [User: 0.861 s, System: 0.305 s]
  Range (min … max):    1.589 s …  1.933 s    10 runs

Summary
      command find (brew --cellar) -mindepth 3 -maxdepth 3 -name '*.service'       | awk -F'homebrew.|.service' '{print }'       | sort -d ran
   28.48 ± 2.29 times faster than     set -l list (brew services list)
    set -e list[1] # Header
    for line in
        echo (string split ' ' )[1]
    end

@razvanazamfirei razvanazamfirei marked this pull request as ready for review February 13, 2024 12:58
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Great idea, thanks @razvanazamfirei!

@MikeMcQuaid MikeMcQuaid merged commit 49ddb57 into Homebrew:master Feb 13, 2024
25 checks passed
@razvanazamfirei razvanazamfirei deleted the fish-completions branch February 13, 2024 14:25
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 15, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants