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
[GSOC] ref-filter: get rid of show_ref_array_item #928
[GSOC] ref-filter: get rid of show_ref_array_item #928
Conversation
When we use `git for-each-ref`, every ref will call `show_ref_array_item()` and allocate its own final strbuf. But we can reuse the final strbuf for each step ref's output. Since `show_ref_array_item()` is not used in many places, we can directly delete `show_ref_array_item()` and use the same logic code to replace it. In this way, the caller can clearly see how the loop work. The performance for `git for-each-ref` on the Git repository itself with performance testing tool `hyperfine` changes from 23.7 ms ± 0.9 ms to 22.2 ms ± 1.0 ms. At the same time, we apply this optimization to `git tag -l` and `git branch -l`, the `git branch -l` performance upgrade from 5.8 ms ± 0.8 ms to 2.7 ms ± 0.2 ms and `git tag -l` performance upgrade from 5.9 ms ± 0.4 ms to 5.4 ms ± 0.4 ms. Since the number of tags in git.git is much more than branches, so this shows that the optimization will be more obvious in those repositories that contain a small number of objects. This approach is similar to the one used by 79ed0a5 (cat-file: use a single strbuf for all output, 2018-08-14) to speed up the cat-file builtin. Signed-off-by: ZheNing Hu <adlternative@gmail.com>
/submit |
Submitted as pull.928.git.1617975348494.gitgitgadget@gmail.com To fetch this version into
To fetch this version to local tag
|
On the Git mailing list, ZheNing Hu wrote (reply to this):
|
This branch is now known as |
This patch series was integrated into seen via git@f20d4b2. |
This patch series was integrated into seen via git@9291910. |
This patch series was integrated into seen via git@22a2752. |
On the Git mailing list, René Scharfe. wrote (reply to this):
|
This patch series was integrated into seen via git@7b65b53. |
On the Git mailing list, ZheNing Hu wrote (reply to this):
|
On the Git mailing list, ZheNing Hu wrote (reply to this):
|
Now
git for-each-ref
can reuse final buf forall refs output, the performance is slightly improved,
This optimization is also applied to
git tag -l
andgit branch -l
.Thanks.
cc: Jeff King peff@peff.net
cc: Junio C Hamano gitster@pobox.com
cc: Christian Couder chriscool@tuxfamily.org
cc: Hariom Verma hariom18599@gmail.com
cc: Eric Sunshine sunshine@sunshineco.com
cc: Derrick Stolee stolee@gmail.com
cc: René Scharfe l.s.r@web.de