Skip to content

perf(tar): cache the parse result of GNU tar help #1362

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

Merged
merged 5 commits into from
Apr 8, 2025

Conversation

akinomyoga
Copy link
Collaborator

@akinomyoga akinomyoga commented Apr 7, 2025

In my setup, the tar completion has been somehow significantly slower than the other completions. It turned out that the help parsing, which is performed for every call of the tar completion, has been the bottleneck. This PR introduces a cache for the parse result, which significantly improves the performance of the tar completion.

The main change is 5a85108. There are other refactoring commits, but those changes are independent.

@akinomyoga akinomyoga changed the title refactor(tar): move variable declarations to the relevant places perf(tar): cache the parse result of GNU tar help Apr 7, 2025
Copy link
Owner

@scop scop left a comment

Choose a reason for hiding this comment

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

LGTM. Separate definition and initialization of variables seems to be something we don't generally do, I wonder if there's a reason for not doing them in one go here as well? Anyway, approved as is or with initialization moved to definitions.

@akinomyoga
Copy link
Collaborator Author

I wonder if there's a reason for not doing them in one go here as well?

Yeah, I also thought about that option. I updated the commit that way. In commit c1e96b7, we initialize _comp_cmd_gtar__parse_help__result when loading the file completions/tar (rather than the first call of _comp_cmd_gtar__parse_help). Now the function _comp_cmd_gtar__parse_help just evaluates "$_comp_cmd_gtar__parse_help__result", so I renamed it to _comp_cmd_gtar__parse_help_load.

@akinomyoga akinomyoga merged commit 247ba7b into scop:main Apr 8, 2025
7 checks passed
@akinomyoga akinomyoga deleted the tar-perf branch April 8, 2025 12:53
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.

2 participants