From: "René Scharfe." <l.s.r@web.de>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Jeff King <peff@peff.net>, Eli Schwartz <eschwartz@archlinux.org>,
git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/2] pretty: add merge and exclude options to %(describe)
Date: Sat, 6 Mar 2021 17:18:52 +0100 [thread overview]
Message-ID: <a28592c5-4a70-1ea8-fd73-959e28b4278d@web.de> (raw)
In-Reply-To: <30f78fce-fe1a-0a50-fa8c-e6fe14a03bf3@web.de>
Am 02.03.21 um 17:00 schrieb René Scharfe.:
> Am 28.02.21 um 16:41 schrieb Ævar Arnfjörð Bjarmason:
>> Instead of taking the trouble of putting a limit in the
>> pretty_print_context so we don't call it N times for the same commit,
>> why not just put the strbuf with the result in that same struct?
>>
>> Then you can have it millions of times, and it won't be any more
>> expensive than the other existing %(format) specifiers (actually cheaper
>> than most).
>
> Each %(describe) placeholder can have a unique set of match or exclude
> arguments. Caching them all would increase the strength of a DoS
> attack. Caching a few of them would be OK, but is ineffective in
> reducing the strength of the attack.
The script at the bottom creates archives that illustrate the issue. On
a repo generated with parameter 10 (10 files with 10 $Format:...$ with
10 %(describe) placeholders, so 1000 total), I get the following number
with v2.30.1, which ignores %(describe):
Benchmark #1: git archive HEAD
Time (mean ± σ): 2.2 ms ± 0.2 ms [User: 0.9 ms, System: 1.0 ms]
Range (min … max): 1.8 ms … 2.8 ms 705 runs
Warning: Command took less than 5 ms to complete. Results might be inaccurate.
The version in next expands all placeholders and takes three orders of
magnitude longer:
Benchmark #1: git archive HEAD
Time (mean ± σ): 2.300 s ± 0.003 s [User: 819.0 ms, System: 1200.0 ms]
Range (min … max): 2.293 s … 2.305 s 10 runs
The proposed patch to expand only a single placeholder gets the runtime
back under control:
Benchmark #1: git archive HEAD
Time (mean ± σ): 4.7 ms ± 0.3 ms [User: 1.8 ms, System: 2.2 ms]
Range (min … max): 4.2 ms … 7.0 ms 451 runs
Warning: Command took less than 5 ms to complete. Results might be inaccurate.
Using parameter 100 takes about a second to create the repo, but the git
archive version in next already needs longer to tar it up than I'm
willing to wait.
#!/bin/sh
n=$1
mkdir $n
cd $n
git init
for i in $(seq $n)
do
awk -v i=$i -v n=$n 'END {
for (j = 0; j < n; j++) {
print "$Format:"
for (k = 0; k < n; k++) {
print "%(describe:exclude=x-" i "-" j "-" k ")"
}
print "$"
}
}' </dev/null >"file$i"
done
git add file*
echo "file* export-subst" >.gitattributes
git add .gitattributes
git commit -m initial
for tagno in $(seq $n)
do
git tag -m "$tagno" "tag$tagno"
done
next prev parent reply other threads:[~2021-03-06 16:20 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-25 0:32 gitattributes export-subst and software versioning Eli Schwartz
2021-02-08 19:46 ` René Scharfe
2021-02-08 22:41 ` Junio C Hamano
2021-02-09 0:19 ` Eli Schwartz
2021-02-09 20:42 ` Junio C Hamano
2021-02-14 10:04 ` René Scharfe
2021-02-14 10:04 ` René Scharfe
2021-02-14 10:04 ` [PATCH 1/2] pretty: add %(describe) René Scharfe
2021-02-14 10:10 ` [PATCH 2/2] pretty: add merge and exclude options to %(describe) René Scharfe.
2021-02-17 18:31 ` Jeff King
2021-02-28 11:22 ` René Scharfe.
2021-02-28 15:41 ` Ævar Arnfjörð Bjarmason
2021-03-02 16:00 ` René Scharfe.
2021-03-06 16:18 ` René Scharfe. [this message]
[not found] ` <xmqqy2f6rc8f.fsf@gitster.c.googlers.com>
2021-03-02 16:00 ` René Scharfe.
[not found] ` <xmqqsg5uletz.fsf@gitster.g>
2021-02-28 11:22 ` René Scharfe.
2021-02-16 5:04 ` [PATCH 1/2] pretty: add %(describe) Eli Schwartz
2021-02-16 13:00 ` Ævar Arnfjörð Bjarmason
2021-02-16 17:13 ` René Scharfe.
2021-02-16 18:44 ` Junio C Hamano
2021-02-17 0:47 ` Ævar Arnfjörð Bjarmason
2021-02-28 11:22 ` René Scharfe.
[not found] ` <xmqq35xesqzk.fsf@gitster.c.googlers.com>
2021-03-02 16:00 ` René Scharfe.
2021-02-17 0:58 ` Ævar Arnfjörð Bjarmason
2021-02-17 18:12 ` Junio C Hamano
2021-02-28 11:22 ` René Scharfe.
[not found] ` <xmqq7dmqsr72.fsf@gitster.c.googlers.com>
2021-03-02 16:00 ` René Scharfe.
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=a28592c5-4a70-1ea8-fd73-959e28b4278d@web.de \
--to=l.s.r@web.de \
--cc=avarab@gmail.com \
--cc=eschwartz@archlinux.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/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).