Repository navigation
feat(comp): Speed up completion of charts - #6809
Conversation
ed7b5bb to
5e59ec2
Compare
|
Although technically not a bug fix, this is only a 2-line change that makes the completion of charts much nicer. The change is safe as it can only affect completion. I wonder if this could be considered for the 3.0 release? The user experience would be much nicer because, when completing the name of a chart, (e.g. |
5e59ec2 to
2dd5afa
Compare
2dd5afa to
3b71917
Compare
|
I reworked this PR in a much less hacky fashion. This new attempt has helm create a new cache file for each repo which contains the list of charts for that repo. Helm will do this whenever it downloads the repo index file. The completion logic then uses this new cache file directly and obtains the chart names very quickly. On the other hand, adding the creation of the new chart-list cache file to |
3b71917 to
c831231
Compare
|
I've just added tests for this change and also fixed the fact that I had forgotten to remove the new cache file when doing a |
bacongobbler
left a comment
There was a problem hiding this comment.
LGTM! I would suggest adding more test coverage for some of the new added functionality, but overall this looks like it solves the issue
| // Create the chart list file in the cache directory | ||
| var charts strings.Builder | ||
| for name := range indexFile.Entries { | ||
| fmt.Fprintln(&charts, name) |
There was a problem hiding this comment.
would you mind writing a unit test for this if possible?
There was a problem hiding this comment.
Will do. Thanks for the review!
There was a problem hiding this comment.
The simplest way to test this was to extend the Index file test of index_test.go.
The latest version of the PR does just that.
46ebd92 to
1cc1e98
Compare
|
This last forced push was just to rebase and to correct the commit message. New tests still pending. |
The completion of charts was using 'helm search repo' which can be quite slow as it must parse the entire yaml of every repo cache file. Using completion for a chart name can end up triggering multiple calls to 'helm search'; this makes the user experience poor, as there is a delay of over a second at every <TAB> press. This commit creates a cache file for each repo which contains the list of charts for that repo. The completion logic then uses this new cache file directly and obtains the chart names very quickly. With only the stable repo configured, this optimization makes the completion of charts about 85 times faster, going from 1.2 seconds to 0.014 seconds; such a difference gives a much better user experience when completing chart names. On the other hand, adding the creation of the chart list cache file to 'helm repo update' or 'helm repo add' is pretty much negligible compared to the downloading of the index file. It is also worth noting that when more repos are configured, 'helm search repo' only becomes slower, while the completion logic that uses the new chart list cache file will not be affected as it only looks for the single relevant repo file. Signed-off-by: Marc Khouzam <[email protected]>
1cc1e98 to
f437b4d
Compare
|
@bacongobbler ready for review again. |
I feel that this improvement in performance when listing charts makes it much more useful to use shell completion when wanting to find a chart.
The completion of charts was using
helm search repowhich can be quite slow as it must parse the entire yaml of every repo cache file.EDIT: please see #6809 (comment) below for a description of the reworked PR.
This commit makes the completion logic access the correct repo cache file directly and only extract the chart names from it.With only the stable repo configured, this optimization makes the completion of charts about 10 times faster, going from 1.1 seconds (which is quite slow for a user doing completion) to 0.14 seconds; such a difference give a much better user experience.If other repos are configured,
helm search repoonly become slower, while the new completion logic will not be affected as it only looks for the relevant single repo file.Notes for maintainers:
Can a maintainer tell me their opinion on the approach of using the cache file by:1- extracting the cache directory by looking for HELM_REPOSITORY_CACHE in the output of
helm env2- greping for chart names (using
\egrep -e '^ [a-zA-Z]'on the$repo-index.yamlcache fileI would have liked something a little more straightforward, but nothing better jumped out at me.This change was tested for backwards-compatibility using the acceptance-testing repo