From: Phillip Wood <phillip.wood123@gmail.com>
To: Tian Yuchen <a3205153416@gmail.com>, git@vger.kernel.org
Cc: gitster@pobox.com, Johannes Sixt <j6t@kdbg.org>
Subject: Re: [PATCH v2] t/perf/p3400: speed up setup using fast-import
Date: Fri, 30 Jan 2026 14:31:58 +0000 [thread overview]
Message-ID: <39b421df-a2cc-4ab4-9aa8-b79c5c172d86@gmail.com> (raw)
In-Reply-To: <20260128160717.611391-1-a3205153416@gmail.com>
On 28/01/2026 16:07, Tian Yuchen wrote:
> The setup phase in 't/perf/p3400-rebase.sh' generates 100 commits to
> simulate a noisy history. It currently uses a shell loop that invokes
> 'git add', 'git commit', 'test_seq', and 'sort' in each iteration.
> This incurs significant overhead due to repeated process spawning.
>
> Optimize the setup by using 'git fast-import' to generate the commit
> history in a single stream. Additionally, pre-compute the forward and
> reversed file contents to avoid repetitive execution of 'seq' and 'sort'.
>
> To ensure the test measures rebase performance against a consistent
> object layout (rather than the suboptimal pack/loose objects created
> by the raw import), perform a full repack (`git repack -a -d`) at the
> end of the setup.
>
> This reduces the setup time significantly while maintaining the validity
> of the subsequent performance tests.
>
> Performance enhancement:
> Real Rebase
> Before: 29.045s 13.34s
> After: 22.231s 12.78s
That's a nice speedup in the test setup
> diff --git a/t/perf/p3400-rebase.sh b/t/perf/p3400-rebase.sh
> index e6b0277729..9f4251aed6 100755
> --- a/t/perf/p3400-rebase.sh
> +++ b/t/perf/p3400-rebase.sh
> @@ -9,25 +9,47 @@ test_expect_success 'setup rebasing on top of a lot of changes' '
> git checkout -f -B base &&
> git checkout -B to-rebase &&
> git checkout -B upstream &&
> - for i in $(test_seq 100)
> - do
> - # simulate huge diffs
> - echo change$i >unrelated-file$i &&
> - test_seq 1000 >>unrelated-file$i &&
> - git add unrelated-file$i &&
> - test_tick &&
> - git commit -m commit$i unrelated-file$i &&
> - echo change$i >unrelated-file$i &&
> - test_seq 1000 | sort -nr >>unrelated-file$i &&
> - git add unrelated-file$i &&
> - test_tick &&
> - git commit -m commit$i-reverse unrelated-file$i ||
> - return 1
> - done &&
> +
> + test_seq 1000 >content_fwd &&
> + test_seq 1000 | sort -nr >content_rev &&
> +
> + (
> + for i in $(test_seq 100)
> + do
> + echo "commit refs/heads/upstream" &&
> + echo "committer WGYDY <author@mock.com> $i +0000" &&
You can keep the same author and committer as the original with
test_tick &&
echo "author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" &&
echo "committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>
$GIT_COMMITTER_DATE" &&
here and below
> + echo "data <<EOF" &&
> + echo "commit$i" &&
> + echo "EOF" &&
> +
> + if test "$i" = 1; then
> + echo "from refs/heads/upstream^0"
> + fi &&
> +
> + echo "M 100644 inline unrelated-file$i" &&
> + echo "data <<EOF" &&
> + echo "change$i" &&
> + cat content_fwd &&
> + echo "EOF" &&
> +
> + echo "commit refs/heads/upstream" &&
> + echo "committer WGYDY <author@mock.com> $i +0000" &&
> + echo "data <<EOF" &&
> + echo "commit$i-reversed" &&
The commit message in the original is "commit$i-reverse", not "reversed"
> + echo "EOF" &&
> + echo "M 100644 inline unrelated-file$i" &&
> + echo "data <<EOF" &&
> + echo "change$i" &&
> + cat content_rev &&
> + echo "EOF" || return 1
> + done
As Johannes pointed out we'll ignore the any failure above. We can
address that by adding "echo done" here and adding "--done" to "git
fast-import" below. That will cause "git fast-import" to fail because if
there is an error in the loop as the last line of input to fast-import
will not be "done"
Thanks
Phillip
> + ) | git fast-import &&
> +
> + git repack -a -d &&
> + git checkout -f upstream &&
> git checkout to-rebase &&
> test_commit our-patch interesting-file
> '
> -
> test_perf 'rebase on top of a lot of unrelated changes' '
> git rebase --onto upstream HEAD^ &&
> git rebase --onto base HEAD^
next prev parent reply other threads:[~2026-01-30 14:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 16:56 [PATCH V1][RFC] t/perf/p3400: speed up setup using fast-import Tian Yuchen
2026-01-26 17:06 ` Tian Yuchen
2026-01-28 4:33 ` Tian Yuchen
2026-01-28 15:25 ` Tian Yuchen
2026-01-28 16:07 ` [PATCH v2] " Tian Yuchen
2026-01-30 6:41 ` Johannes Sixt
2026-01-30 9:55 ` Johannes Sixt
2026-01-30 16:27 ` Junio C Hamano
[not found] ` <b6f12614-ecc1-4d37-ac4c-070925054f28@gmail.com>
2026-01-30 16:47 ` Johannes Sixt
2026-01-30 14:31 ` Phillip Wood [this message]
2026-01-30 15:40 ` Tian Yuchen
2026-01-30 16:29 ` [PATCH v3] " Tian Yuchen
2026-01-30 17:01 ` [PATCH v4] " Tian Yuchen
2026-01-30 17:10 ` [PATCH v3] " Junio C Hamano
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=39b421df-a2cc-4ab4-9aa8-b79c5c172d86@gmail.com \
--to=phillip.wood123@gmail.com \
--cc=a3205153416@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=phillip.wood@dunelm.org.uk \
/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