From: "ZheNing Hu via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Jeff King" <peff@peff.net>, "Junio C Hamano" <gitster@pobox.com>,
"Christian Couder" <chriscool@tuxfamily.org>,
"Hariom Verma" <hariom18599@gmail.com>,
"Eric Sunshine" <sunshine@sunshineco.com>,
"Derrick Stolee" <stolee@gmail.com>,
"René Scharfe" <l.s.r@web.de>,
"ZheNing Hu" <adlternative@gmail.com>
Subject: [PATCH v2 0/2] [GSOC] ref-filter: reuse output buffer
Date: Tue, 20 Apr 2021 16:52:09 +0000 [thread overview]
Message-ID: <pull.935.v2.git.1618937532.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.935.git.1618831726.gitgitgadget@gmail.com>
* Firstly, inlining show_ref_array_item().
* Secondly, git for-each-ref reuse final buf for all refs output, the
performance is slightly improved, this optimization is also applied to
git tag -l and git branch -l.
Changes made in v2: reset err buffer in loop for code cleanness.
Thanks.
ZheNing Hu (2):
[GSOC] ref-filter: get rid of show_ref_array_item
[GSOC] ref-filter: reuse output buffer
builtin/branch.c | 10 ++++++----
builtin/for-each-ref.c | 15 +++++++++++++--
builtin/tag.c | 15 +++++++++++++--
ref-filter.c | 25 ++++++++++---------------
ref-filter.h | 2 --
5 files changed, 42 insertions(+), 25 deletions(-)
base-commit: 2e36527f23b7f6ae15e6f21ac3b08bf3fed6ee48
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-935%2Fadlternative%2Fref-filter-opt-reuse-buf-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-935/adlternative/ref-filter-opt-reuse-buf-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/935
Range-diff vs v1:
1: ec98f2177d90 ! 1: 7e378eef4b34 [GSOC] ref-filter: get rid of show_ref_array_item
@@ Metadata
## Commit message ##
[GSOC] ref-filter: get rid of show_ref_array_item
- Inlining the exported function `show_ref_array_item()`
+ Inlining the exported function `show_ref_array_item()`,
which is not providing the right level of abstraction,
simplifies the API and can unlock improvements at the
former call sites.
2: 1c7a69ba072a ! 2: a17949b9f809 [GSOC] ref-filter: reuse output buffer
@@ Commit message
[GSOC] ref-filter: reuse output buffer
When we use `git for-each-ref`, every ref will allocate
- its own output strbuf. But we can reuse the final strbuf
- for each step ref's output.
+ its own output strbuf and error strbuf. But we can reuse
+ the final strbuf for each step ref's output. The error
+ buffer will also be reused, despite the fact that the git
+ will exit when `format_ref_array_item()` return a non-zero
+ value and output the contents of the error buffer.
The performance for `git for-each-ref` on the Git repository
itself with performance testing tool `hyperfine` changes from
@@ Commit message
(cat-file: use a single strbuf for all output, 2018-08-14)
to speed up the cat-file builtin.
+ Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Jeff King <peff@peff.net>
Helped-by: René Scharfe <l.s.r@web.de>
Signed-off-by: ZheNing Hu <adlternative@gmail.com>
@@ builtin/branch.c: static void print_ref_list(struct ref_filter *filter, struct r
for (i = 0; i < array.nr; i++) {
- struct strbuf out = STRBUF_INIT;
- struct strbuf err = STRBUF_INIT;
++ strbuf_reset(&err);
+ strbuf_reset(&out);
if (format_ref_array_item(array.items[i], format, &out, &err))
die("%s", err.buf);
@@ builtin/for-each-ref.c: int cmd_for_each_ref(int argc, const char **argv, const
- struct strbuf output = STRBUF_INIT;
- struct strbuf err = STRBUF_INIT;
-
++ strbuf_reset(&err);
+ strbuf_reset(&output);
if (format_ref_array_item(array.items[i], &format, &output, &err))
die("%s", err.buf);
@@ builtin/tag.c: static int list_tags(struct ref_filter *filter, struct ref_sortin
- struct strbuf err = STRBUF_INIT;
-
+ strbuf_reset(&output);
++ strbuf_reset(&err);
if (format_ref_array_item(array.items[i], format, &output, &err))
die("%s", err.buf);
fwrite(output.buf, 1, output.len, stdout);
--
gitgitgadget
next prev parent reply other threads:[~2021-04-20 16:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-19 11:28 [PATCH 0/2] [GSOC] ref-filter: reuse output buffer ZheNing Hu via GitGitGadget
2021-04-19 11:28 ` [PATCH 1/2] [GSOC] ref-filter: get rid of show_ref_array_item ZheNing Hu via GitGitGadget
2021-04-19 20:54 ` Junio C Hamano
2021-04-19 11:28 ` [PATCH 2/2] [GSOC] ref-filter: reuse output buffer ZheNing Hu via GitGitGadget
2021-04-19 21:04 ` Junio C Hamano
2021-04-20 6:05 ` ZheNing Hu
2021-04-20 16:52 ` ZheNing Hu via GitGitGadget [this message]
2021-04-20 16:52 ` [PATCH v2 1/2] [GSOC] ref-filter: get rid of show_ref_array_item ZheNing Hu via GitGitGadget
2021-04-20 16:52 ` [PATCH v2 2/2] [GSOC] ref-filter: reuse output buffer ZheNing Hu via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.935.v2.git.1618937532.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=adlternative@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hariom18599@gmail.com \
--cc=l.s.r@web.de \
--cc=peff@peff.net \
--cc=stolee@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).