From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: yusuke8h@gmail.com, git@vger.kernel.org, Jeff King <peff@peff.net>
Subject: Re: [PATCH v2] http-backend: drop strbuf pre-sizing from get_info_packs()
Date: Mon, 16 Nov 2026 07:24:35 -0800 [thread overview]
Message-ID: <xmqqy0asn6j0.fsf@gitster.g> (raw)
In-Reply-To: <avqi2Jpd-QT5iNU9@pks.im> (Patrick Steinhardt's message of "Mon, 16 Nov 2026 07:29:44 +0100")
Patrick Steinhardt <ps@pks.im> writes:
>> This pre-sizing dates back to 2f4038ab33 (Git-aware CGI to provide dumb
>> HTTP transport, 2009-10-30): `53` assumes the length of a SHA-1
>> "P pack-<hex>.pack\n" line (under-counting the 77-byte lines in SHA-256
>> repositories), and `cnt * 53 + 2` uses unchecked arithmetic.
>> ...
> Yeah, that's a much more convincing message. The other angle that this
> is missing a bit is that giving a size hint ensures that we allocate
> exactly as many bytes as we need. But that shouldn't matter in the
> general case, and if you have to allocate gigabytes of memory to store
> the list of packfiles... well, then you really have bigger problems to
> worry about.
Yeah, miscounting the preallocation is not a bug and just doing
pointless work. I agree with you that for the purpose of sizing
strbuf, you have a larger issue if you have to worry about
overflowing arithmetic.
> So I think this version is good enough, thanks!
Thanks.
prev parent reply other threads:[~2026-11-16 15:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 2:17 [PATCH] http-backend: drop strbuf pre-sizing from get_info_packs() Yusuke Hayashi via B4 Relay
2026-11-13 7:03 ` Patrick Steinhardt
2026-11-15 9:58 ` Yusuke Hayashi
2026-11-15 9:58 ` [PATCH v2] " Yusuke Hayashi via B4 Relay
2026-11-16 6:29 ` Patrick Steinhardt
2026-11-16 15:24 ` Junio C Hamano [this message]
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=xmqqy0asn6j0.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=ps@pks.im \
--cc=yusuke8h@gmail.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox