perf: avoid dirname in activation shell hooks#550
Open
nickajacks1 wants to merge 4 commits intocashapp:masterfrom
Open
perf: avoid dirname in activation shell hooks#550nickajacks1 wants to merge 4 commits intocashapp:masterfrom
nickajacks1 wants to merge 4 commits intocashapp:masterfrom
Conversation
Repeated forking of a dirname process can get rather heavy in deep directory structures, especially with distributions that are moving to uutils. This is most problematic for bash, which runs PROMPT_COMMAND for every prompt as opposed to zsh and fish which run the activation check on chdir. Switching to a pure shell calculation of the parent directory makes performance scale much better. On an Intel Core Ultra 7 165H with uutils, the existing dirname solution takes about 30 milliseconds to traverse 10 directories, which is enough to be noticeable. Using the updated pure shell approach reduces the time down to 5-10 milliseconds at a directory depth of 80.
Contributor
Author
|
I didn't make the change to the fish scripts because I figured only running on |
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.
Repeated forking of a dirname process can get rather heavy in deep directory structures, especially with distributions that are moving to uutils. This is most problematic for bash, which runs PROMPT_COMMAND for every prompt as opposed to zsh and fish which run the activation check on chdir. Switching to a pure shell calculation of the parent directory makes performance scale much better.
On an Intel Core Ultra 7 165H with uutils, the existing dirname solution takes about 30 milliseconds to traverse 10 directories, which is enough to be noticeable. Using the updated pure shell approach reduces the time down to 5-10 milliseconds at a directory depth of 80.