Article View: linux.kernel.git
Article #3156Re: [PATCH] http-backend: drop strbuf pre-sizing from get_info_packs()
From: Yusuke Hayashi
Date: Sun, 15 Nov 2026 09:58
Date: Sun, 15 Nov 2026 09:58
31 lines
13211 bytes
13211 bytes
On Fri, Nov 13, 2026 at 08:03:52AM +0100, Patrick Steinhardt wrote: > So this explains that the behaviour is buggy, but that may lead the > reader to wonder why we don't just fix the bug. And sure, we know to > grow the buffer automatically, but the hint is intended as a performance > improvement so that we know to allocate the buffer properly right from > the start. > > Note that I'm not saying that this change doesn't make sense. But I > think the argument that "others do it" is rather weak. The more > important question to answer is why it's fine to skip it in this > particular function. Fair point -- pointing out the SHA-256 under-count and unchecked multiplication without explaining why we don't just fix the formula leaves the main question unanswered, and citing a9ce8526dc doesn't answer it for get_info_packs() either. In this case, get_info_packs() is a one-shot CGI handler for dumb HTTP GET /objects/info/packs requests that formats a single response and exits. A typical repository only produces a few kilobytes of output, and even with thousands of packs strbuf's geometric growth only needs a couple dozen reallocations, which is negligible compared to CGI startup, scanning objects/pack to populate the pack list, and writing the HTTP response. Meanwhile, computing the hint up front requires an extra pass over the pack list. I'll send a v2 with an updated commit message that explains this directly instead. Thanks for the review!
Technical Details
Message-ID:
<CAB59oQ_K=AdVk+xXVPkodP_tPfGWuLO0fqvBwJAz2tvBAxrb7g@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75481-linux-kernel-git=dewy.ruReferences:
<20261113-http-backend-drop-strbuf-presizing-v1-1-7d66aae03b22@gmail.com> <ava2WJkDag6-uthA@pks.im>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-75481-linux-kernel-git=dewy.ru
From: yusuke8h@gmail.com (Yusuke Hayashi)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] http-backend: drop strbuf pre-sizing from get_info_packs()
Date: Sun, 15 Nov 2026 01:58:29 -0800
Organization: Usenet Network
Message-ID: <CAB59oQ_K=AdVk+xXVPkodP_tPfGWuLO0fqvBwJAz2tvBAxrb7g@mail.gmail.com>
References: <20261113-http-backend-drop-strbuf-presizing-v1-1-7d66aae03b22@gmail.com>
<ava2WJkDag6-uthA@pks.im>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Info: usenet.network;
logging-data="1767869"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:dMBiUfGbhIJzqu/sK7zM4TMJrpQ= sha256:JUDYgNULWUIGvd6BTewaQH5l2b5Mf6Bvk1TBrkE2wug=
sha1:7Im9HuWZpstDT29UArMvsg3UXNc= sha256:2MNMLvh702mEK5reEByv/UPXuml+rAy21ZF2jizdD1g=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id B396F114997; Sun, 15 Nov 2026 12:58:55 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id Rf6aFuvUrRFP;
Sun, 15 Nov 2026 12:58:52 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-75481-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id B72A9114991; Sun, 15 Nov 2026 12:58:44 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id 59CBD60BDF5; Sun, 15 Nov 2026 09:58:32 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794736711;
b=rN3OnrdaiPevKb6tKAzjs5rlMIrf/AH/EAyNQP26O+0OBFOegojz8WyW4Gb4rlxvLA01
CHX1Sgs67V+o7iYxV23RIKWehPGXZx3w+eSdV693KB66BbbwcLP0GLbbTW8YmoSx+Yegl
XavrMP/ZUyfHCHIMrRNA7q7tN3T7Ci+ho6/jsgKLxorQ5WYoVcPkKGIGb31spjbBy53B4
6rCAMzc8cJzOTyrVFB9UlnDzst3CEII1HZAnWbRdteLAmQgVLeqvDKI2HbZR/zc8XTCIO
cNmqsg1wjpTDoRLWNzsdU8DC2xxq+xXtEqBP7+mjYtnuNmnfmx+BmUx+lFZsvECVD2Q==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794736711;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Received:From:In-Reply-To:References:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Date:X-Gm-Features:Message-ID:Subject:To:Cc:
Content-Type;
bh=98Q1dM4Klm1eSbtJug57EYv5a2W/cYY+OFDG1LyO0f0=;
b=spFaq3BAQdC8rTTl/+KU8CID0Z8FSO6WYlJuZqv0skhvjseJWbgzN7rDxEx/A/UtibTD
M1kY796b/8T6FYq1VC45zDRD64zazjETTuuHJP+nx44thRWGHZToqYlRidX55qrzgEGVH
sLCvyr34M700tDW3h7/P7rbVgjmh4/P14WfM76HDHbiqzsaBqbxoIKVjyJfj/0DP0wKhi
lGsqMKrwoKD/nkS/4aD2i+PVZMRD6pXKoiOBOtiElOV8pLOjyl7DxsBn7owITUs2R+9Ne
5dFovRWDj556/3uOOtiXQF5GqZtWVVougOkevfyehjMuOWI04jK0dQvFFMGAMegHqIg==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qNWdQmfo;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id C75E9606A323;
Sun, 15 Nov 2026 09:58:31 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qNWdQmfo
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.128.170
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794736711;
b=RBwPm6LeTTHowQsUJ72Ef+vnaXCABBkXKeTSJDfYFMJ2uK7SJn/kzMwaC1WZ+b0/UvvP
lcBz3IBkLp5d2fBWShT5dQWs7KGGUzOHJtVRTtjTogmFgbWYA2vlotzlPCtpI4F1apUIj
qVTU5N3WDPAX4PPKzmx9nqfe+8AEAb9wit5Q4pVRC3TQyiP2HT7I5tEWIKBReK7sgh3iO
x0HtsSwBP/G5uu8bc8G3ggJ2Jfvn+m+qjn7rDNPdZy9xXw/5KYWj2Qty81hIo1U+tuzlB
65/yp0TBshpkiVH9ALgBoNAQkTI5wHYn7zegN237sH9ZOu4RJDSwGBcqADYye6AYaPA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794736711;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Received:From:
In-Reply-To:References:MIME-Version:Date:X-Gm-Features:Message-ID:
Subject:To:Cc:Content-Type;
bh=98Q1dM4Klm1eSbtJug57EYv5a2W/cYY+OFDG1LyO0f0=;
b=Y6vvdvSMn6sj4r6FEQuiXxVoF1tiP2clCdKkRsL3LNucqobBIatiBL9N2uX3XALz+VBQ
ygjlDshsIkAMcYme1lbrOWIR4Luk+/ru1PUNnz9tHTY7Ly5AtK4fYMicm7eOEGjrl3FY2
12Xpbuq8B2g+dJJyXLrxAm75P2YkkaXP9e19LRhrDOlKmqOq5REfcQ4Zphi4TiBA4zNYS
363AvtIEWSE4WPbiDJavw7m0qcwYuDraoV66O00HWM3LLisGaXrcq+llmP3d9zXM56Jbu
naEt/UiHshXRLmc0/utbPA1RroEeE2bl1YShg16YQfU1OoCrkeJTo+q00y2mVCitUUQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=qNWdQmfo;
arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.128.170
X-Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 99EC3606A31A
for <git@vger.kernel.org>; Sun, 15 Nov 2026 09:58:30 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 99EC3606A31A
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-8b4c2da74c0so2959577b3.1
for <git@vger.kernel.org>; Sun, 15 Nov 2026 01:58:30 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1794736709; cv=none;
d=google.com; s=arc-20260327;
b=H4Dks0PqWv75Sf0ROGfO7iYoaNkofE1EWXPff85J1129CNpWZbqCInq3ZGdZncfPB6
rNApiB9nFrEVMvdnZlT6R3XUbjNLMABSZA9dQyYxS5+9UWL1ABOLLF4tCtLwWKBG9hj0
vHrX75qWmuiCVSs9w/oBo6EwWnhgH5Swr4S54suOQFIDeTKcXmhjVul1HBFL4x0NPJeQ
kzLafz0zxDw8V6ARVs+6n0mFbMj4spVJgWEMI4+47TzP2myB/4uRIpZ/iL8T2TlKxHWJ
XKBzPDqQFA0fdJuWhMveR1cHqr9xECMBeaE9VfCjRpcnc8BGAQdiW+GEGQieMQTNI4u9
jJsw==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
:from:dkim-signature;
bh=98Q1dM4Klm1eSbtJug57EYv5a2W/cYY+OFDG1LyO0f0=;
fh=7QBgNa8+WZXNYeI7qrTp8WO+duC+GtsTe+dnvwJN9+Q=;
b=fMtzyrQDvvemstpntDmA4m3aqhiMDCkWHMxHtjLqCPCXO5x/l06bJxAPK/1bYcENKf
GHytaLeQ52Xrty189apSmqBK52PvhYDXFtwsSG5ZhGkAIj2WYWrZjcen0Yk2pg5ubzOA
lS51rhiSNBbIFbEqUM2VEc0ABNb4Jz9zK3Yg2PxarkhSnfEvbt3fQTgFF484aXSXUpde
xpstuv3VbAyAZkp8lAkC4Yw82I+JAG2M9YqEUGoHc1FDX98XZW2oDSYk66wVpsjs++hd
8gJPvjyWKxaAxTlwnlLOQnrTfUi7pieCpIAd7fiinwt1KonpHo2yr5c33LvCxpZJ0Y82
moSw==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794736709; x=1795341509; darn=vger.kernel.org;
h=content-type:cc:to:subject:message-id:date:mime-version:references
:in-reply-to:from:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=98Q1dM4Klm1eSbtJug57EYv5a2W/cYY+OFDG1LyO0f0=;
b=qNWdQmfooCt4n44f3AN5ucm4RVXYl0EZF2N5aDiOBWXpVXfmsw2iGe+dFe0D+8D7LP
bJOZGA1rvQoBjSViXbe591cRusXSjIEsXPLSYIdejl7teidOlXPQu7UoSeU/Q2w5Xplb
jbCHhkkMyar/BfMeluZLLOxbpyd89+DBbsfcVeVObmx8xTCUfEZzqLB9faaUMOuCT1WX
ISU8hympDWO3g/SNCwSa3AQ9twBUqAyp6scTSHSVkFQ4DopbJJxIrg/3nwLuU8KCJgJv
N2EvLiqps9G0zjTWMuXleeh3i+gDHoV0608/pahYXRbBuoxRSBSH4gbTLBIv50VNbo1p
pCKw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794736709; x=1795341509;
h=content-type:cc:to:subject:message-id:date:mime-version:references
:in-reply-to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=98Q1dM4Klm1eSbtJug57EYv5a2W/c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by 2002:a05:690c:c4f1:b0:8b4:d44a:c4ca with SMTP id
00721157ae682-8b4d45a0d54mr2805807b3.24.1794736709468; Sun, 15 Nov 2026
01:58:29 -0800 (PST)
X-Received: from 1087654160852 named unknown by gmailapi.google.com with
HTTPREST; Sun, 15 Nov 2026 01:58:29 -0800
X-Received: from 1087654160852 named unknown by gmailapi.google.com with
HTTPREST; Sun, 15 Nov 2026 04:58:08 -0500
X-In-Reply-To: <ava2WJkDag6-uthA@pks.im>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-Gm-Features: AclHuK_n29GegGRCptw7Vjqb2R-XeW5RENmSRiPELzgqPGL9IFzX58ADbxDhdAs
X-Cc: git@vger.kernel.org, Jeff King <peff@peff.net>