git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Taylor Blau <me@ttaylorr.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 08/10] t5401: speed up creation of many branches
Date: Wed, 29 Nov 2023 17:25:24 -0500	[thread overview]
Message-ID: <ZWe6VDZqW8zCzMNJ@nand.local> (raw)
In-Reply-To: <f674119c7801e355cd08a651450abd67947d7456.1701242407.git.ps@pks.im>

On Wed, Nov 29, 2023 at 08:25:09AM +0100, Patrick Steinhardt wrote:
> One of the tests in t5401 creates a bunch of branches by calling
> git-branch(1) for every one of them. This is quite inefficient and takes
> a comparatively long time even on Unix systems where spawning processes
> is comparatively fast. Refactor it to instead use git-update-ref(1),
> which leads to an almost 10-fold speedup:
>
> ```
> Benchmark 1: ./t5401-update-hooks.sh (rev = HEAD)
>   Time (mean ± σ):     983.2 ms ±  97.6 ms    [User: 328.8 ms, System: 679.2 ms]
>   Range (min … max):   882.9 ms … 1078.0 ms    3 runs
>
> Benchmark 2: ./t5401-update-hooks.sh (rev = HEAD~)
>   Time (mean ± σ):      9.312 s ±  0.398 s    [User: 2.766 s, System: 6.617 s]
>   Range (min … max):    8.885 s …  9.674 s    3 runs
>
> Summary
>   ./t5401-update-hooks.sh (rev = HEAD) ran
>     9.47 ± 1.02 times faster than ./t5401-update-hooks.sh (rev = HEAD~)

Very nice ;-).

> diff --git a/t/t5401-update-hooks.sh b/t/t5401-update-hooks.sh
> index 001b7a17ad..8b8bc47dc0 100755
> --- a/t/t5401-update-hooks.sh
> +++ b/t/t5401-update-hooks.sh
> @@ -133,10 +133,8 @@ test_expect_success 'pre-receive hook that forgets to read its input' '
>  	EOF
>  	rm -f victim.git/hooks/update victim.git/hooks/post-update &&
>
> -	for v in $(test_seq 100 999)
> -	do
> -		git branch branch_$v main || return
> -	done &&
> +	printf "create refs/heads/branch_%d main\n" $(test_seq 100 999) >input &&
> +	git update-ref --stdin <input &&

Not that it really matters here, but you could pipe the output of your
printf directly into git update-ref. I don't think we rely on the value
of "input" after this point, and git is on the right-hand side of the
pipe, so this is safe to do.

But it doesn't matter much either way, just something I noticed while
reading.

Thanks,
Taylor

  reply	other threads:[~2023-11-29 22:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29  7:24 [PATCH 00/10] t: more compatibility fixes with reftables Patrick Steinhardt
2023-11-29  7:24 ` [PATCH 01/10] t0410: mark tests to require the reffiles backend Patrick Steinhardt
2023-11-29 22:19   ` Taylor Blau
2023-11-29  7:24 ` [PATCH 02/10] t1400: split up generic reflog tests from the reffile-specific ones Patrick Steinhardt
2023-11-29  7:24 ` [PATCH 03/10] t1401: stop treating FETCH_HEAD as real reference Patrick Steinhardt
2023-11-29  7:24 ` [PATCH 04/10] t1410: use test-tool to create empty reflog Patrick Steinhardt
2023-11-29  7:24 ` [PATCH 05/10] t1417: make `reflog --updateref` tests backend agnostic Patrick Steinhardt
2023-11-29  7:25 ` [PATCH 06/10] t3310: stop checking for reference existence via `test -f` Patrick Steinhardt
2023-11-29  7:25 ` [PATCH 07/10] t4013: simplify magic parsing and drop "failure" Patrick Steinhardt
2023-11-29  7:25 ` [PATCH 08/10] t5401: speed up creation of many branches Patrick Steinhardt
2023-11-29 22:25   ` Taylor Blau [this message]
2023-11-29  7:25 ` [PATCH 09/10] t5551: stop writing packed-refs directly Patrick Steinhardt
2023-11-29 22:26   ` Taylor Blau
2023-11-29  7:25 ` [PATCH 10/10] t6301: write invalid object ID via `test-tool ref-store` Patrick Steinhardt
2023-11-29 23:30 ` [PATCH 00/10] t: more compatibility fixes with reftables Taylor Blau
2023-11-30  7:06   ` Patrick Steinhardt

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZWe6VDZqW8zCzMNJ@nand.local \
    --to=me@ttaylorr.com \
    --cc=git@vger.kernel.org \
    --cc=ps@pks.im \
    /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.
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 NNTP newsgroup(s).