From: "SZEDER Gábor" <szeder.dev@gmail.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH 3/9] t4141: fix inefficient use of dd(1)
Date: Thu, 2 Jul 2026 19:49:50 +0200 [thread overview]
Message-ID: <akakvnoAswZx+DNI@szeder.dev> (raw)
In-Reply-To: <20260702-b4-pks-t-fixes-for-GIT-TEST-LONG-v1-3-76b4d7bab3d0@pks.im>
On Thu, Jul 02, 2026 at 02:00:56PM +0200, Patrick Steinhardt wrote:
> In t4141 we generate a patch that is roughly 1GB in size to verify that
> git-apply(1) indeed rejects that patch. We generate that patch by
> prepending a patch header and then executing `test-tool genzeros`
> without a limit. This causes us to print infinitely many zeros, and we
> limit the overall amount of generated bytes via `test_copy_bytes`.
>
> This test setup is extremely expensive, as `test_copy_bytes` is
> implemented via `dd ibs=1 count="$1"`, which copies data one byte at a
> time. So as we write 1GB of data, we end up doing 1 billion reads and
> writes. This naturally takes a while: it takes 6 minutes on my system,
> and around 40 minutes in some CI jobs!
>
> We can do much better though, as genzeros already knows to handle an
> optional limit of how much data it is supposed to write, which allows us
> to remove the call to `test_copy_bytes`. Furthermore, it has already
> been optimized to generate the data fast.
>
> And indeed, doing this conversion drops the test execution to less than
> a second on my machine, so that we can drop the EXPENSIVE prerequisite.
EXPENSIVE is not only about execution time, but about resources in
general. While the modified test finishes quite fast indeed, 'git
apply' uses over 1GB of RSS. Therefore, the EXPENSIVE prerequisite
should be kept.
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> t/t4141-apply-too-large.sh | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/t/t4141-apply-too-large.sh b/t/t4141-apply-too-large.sh
> index eac6f7e151..dad67779ed 100755
> --- a/t/t4141-apply-too-large.sh
> +++ b/t/t4141-apply-too-large.sh
> @@ -4,8 +4,7 @@ test_description='git apply with too-large patch'
>
> . ./test-lib.sh
>
> -test_expect_success EXPENSIVE 'git apply rejects patches that are too large' '
> - sz=$((1024 * 1024 * 1023)) &&
> +test_expect_success 'git apply rejects patches that are too large' '
> {
> cat <<-\EOF &&
> diff --git a/file b/file
> @@ -14,8 +13,8 @@ test_expect_success EXPENSIVE 'git apply rejects patches that are too large' '
> +++ b/file
> @@ -0,0 +1 @@
> EOF
> - test-tool genzeros
> - } | test_copy_bytes $sz | test_must_fail git apply 2>err &&
> + test-tool genzeros $((1024 * 1024 * 1023))
> + } | test_must_fail git apply 2>err &&
> grep "patch too large" err
> '
>
>
> --
> 2.55.0.795.g602f6c329a.dirty
>
next prev parent reply other threads:[~2026-07-02 17:49 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-02 12:00 [PATCH 0/9] t: fixes and improvements for GIT_TEST_LONG Patrick Steinhardt
2026-07-02 12:00 ` [PATCH 1/9] README: add GitLab CI badge to make it more discoverable Patrick Steinhardt
2026-07-02 12:00 ` [PATCH 2/9] t0021: skip EXPENSIVE test that is broken without SIZE_T_IS_32BIT Patrick Steinhardt
2026-07-02 12:00 ` [PATCH 3/9] t4141: fix inefficient use of dd(1) Patrick Steinhardt
2026-07-02 17:49 ` SZEDER Gábor [this message]
2026-07-03 5:42 ` Patrick Steinhardt
2026-07-02 21:16 ` Jeff King
2026-07-03 5:42 ` Patrick Steinhardt
2026-07-03 7:00 ` Jeff King
2026-07-02 12:00 ` [PATCH 4/9] t5608: reduce maximum disk usage Patrick Steinhardt
2026-07-02 12:00 ` [PATCH 5/9] t7508: skip EXPENSIVE test that is broken without SIZE_T_IS_32BIT Patrick Steinhardt
2026-07-02 21:22 ` Jeff King
2026-07-02 22:18 ` Jeff King
2026-07-02 12:00 ` [PATCH 6/9] t7900: clean up large EXPENSIVE repository Patrick Steinhardt
2026-07-02 21:30 ` Jeff King
2026-07-03 5:42 ` Patrick Steinhardt
2026-07-03 7:00 ` Jeff King
2026-07-02 12:01 ` [PATCH 7/9] t: use `test_bool_env` to parse GIT_TEST_LONG Patrick Steinhardt
2026-07-02 12:01 ` [PATCH 8/9] gitlab-ci: disable RAM disk on macOS jobs Patrick Steinhardt
2026-07-02 12:01 ` [PATCH 9/9] gitlab-ci: enable "GIT_TEST_LONG" Patrick Steinhardt
2026-07-03 9:24 ` [PATCH v2 0/9] t: fixes and improvements for GIT_TEST_LONG Patrick Steinhardt
2026-07-03 9:24 ` [PATCH v2 1/9] README: add GitLab CI badge to make it more discoverable Patrick Steinhardt
2026-07-03 9:24 ` [PATCH v2 2/9] t0021: skip EXPENSIVE test that is broken without SIZE_T_IS_32BIT Patrick Steinhardt
2026-07-03 17:36 ` Junio C Hamano
2026-07-06 6:23 ` Patrick Steinhardt
2026-07-03 9:24 ` [PATCH v2 3/9] t4141: fix inefficient use of dd(1) Patrick Steinhardt
2026-07-03 9:24 ` [PATCH v2 4/9] t5608: reduce maximum disk usage Patrick Steinhardt
2026-07-03 9:24 ` [PATCH v2 5/9] t7508: skip EXPENSIVE test that is broken without SIZE_T_IS_32BIT Patrick Steinhardt
2026-07-03 17:38 ` Junio C Hamano
2026-07-03 9:24 ` [PATCH v2 6/9] t7900: clean up large EXPENSIVE repository Patrick Steinhardt
2026-07-03 9:24 ` [PATCH v2 7/9] t: use `test_bool_env` to parse GIT_TEST_LONG Patrick Steinhardt
2026-07-03 9:24 ` [PATCH v2 8/9] gitlab-ci: disable RAM disk on macOS jobs Patrick Steinhardt
2026-07-03 9:24 ` [PATCH v2 9/9] gitlab-ci: enable "GIT_TEST_LONG" Patrick Steinhardt
2026-07-06 6:23 ` [PATCH v3 0/9] t: fixes and improvements for GIT_TEST_LONG Patrick Steinhardt
2026-07-06 6:23 ` [PATCH v3 1/9] README: add GitLab CI badge to make it more discoverable Patrick Steinhardt
2026-07-06 6:23 ` [PATCH v3 2/9] t0021: skip EXPENSIVE test that is broken without SIZE_T_IS_64BIT Patrick Steinhardt
2026-07-06 6:23 ` [PATCH v3 3/9] t4141: fix inefficient use of dd(1) Patrick Steinhardt
2026-07-06 6:23 ` [PATCH v3 4/9] t5608: reduce maximum disk usage Patrick Steinhardt
2026-07-06 6:24 ` [PATCH v3 5/9] t7508: skip EXPENSIVE test that is broken without SIZE_T_IS_64BIT Patrick Steinhardt
2026-07-06 6:24 ` [PATCH v3 6/9] t7900: clean up large EXPENSIVE repository Patrick Steinhardt
2026-07-06 6:24 ` [PATCH v3 7/9] t: use `test_bool_env` to parse GIT_TEST_LONG Patrick Steinhardt
2026-07-06 6:24 ` [PATCH v3 8/9] gitlab-ci: disable RAM disk on macOS jobs Patrick Steinhardt
2026-07-06 6:24 ` [PATCH v3 9/9] gitlab-ci: enable "GIT_TEST_LONG" Patrick Steinhardt
2026-07-06 20:29 ` [PATCH v3 0/9] t: fixes and improvements for GIT_TEST_LONG 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=akakvnoAswZx+DNI@szeder.dev \
--to=szeder.dev@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--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