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 performance on zsh #18220

Closed
wants to merge 1 commit into from

Conversation

ZhongRuoyu
Copy link
Member

  • 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?

By avoiding unneeded brew calls we can make zsh completions much faster.

As a rough measurement, completion for brew list used to take ~4s on my machine, but now it's instant.

By avoiding unneeded `brew` calls we can make zsh completions
much faster.

As a rough measurement, completion for `brew list` used to take ~4s on
my machine, but now it's instant.
@Bo98
Copy link
Member

Bo98 commented Sep 2, 2024

As a rough measurement, completion for brew list used to take ~4s on my machine, but now it's instant.

This is suspicious. brew list should already be implemented in bash and does ls under the hood. Why is the behaviour different?

@Bo98
Copy link
Member

Bo98 commented Sep 2, 2024

Try #18223. It should fix the performance for you without needing these changes.

@ZhongRuoyu
Copy link
Member Author

Now that we have #18223, do we still want to keep the non-brew list changes though? Actually what I did (including removing brew list calls) was copy over what bash completions are doing (bash completions are fast). So even with the list.sh fix, completion for tap names is still slow.

Or we could consider reworking brew tap and migrating over Bash completions to calling brew commands directly too (to reduce discrepancy).

@Bo98
Copy link
Member

Bo98 commented Sep 2, 2024

Repository change is OK if we do so consistently across all completions (assuming it is shown to have actual measurable speed gains).

brew tap is a weird one as the bash completion code is actually older. In any case, if there's a noticeable speed increase it would be better for it to be implemented on command level as:

  • It is shared between all completions
  • It can benefit non-completion cases
  • It can be unit tested in CI

Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the stale No recent activity label Sep 24, 2024
@ZhongRuoyu
Copy link
Member Author

I've opened #18402 that supersedes this. The performance improvement for non-brew tap changes here is insignificant so I'm leaving it out for now.

@ZhongRuoyu ZhongRuoyu closed this Sep 24, 2024
@ZhongRuoyu ZhongRuoyu deleted the zsh-completions-speedup branch September 24, 2024 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale No recent activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants