Article View: linux.kernel.git
Article #3964Re:Re: [PATCH] read-cache: hash the shared index even with index.skipHash
From: "Xing Xin"
Date: Fri, 27 Nov 2026 12:59
Date: Fri, 27 Nov 2026 12:59
125 lines
17964 bytes
17964 bytes
At 2026-11-27 03:21:26, "Junio C Hamano" <gitster@pobox.com> wrote:
> It is correct to point out that the two "features", skipHash and
> splitIndex, are incompatible. With skipHash, splitIndex will not
> correctly work. We can say skipHash breaks splitIndex.
>
> But does this change to _force_ the base index files to be hashed,
> against the user's wish expressed by skipHash, take us in a better
> direction, I have to wonder? With this change, skipHash's promise to
> improve performance is not kept. We can say splitIndex breaks skipHash.
You are right, and the log message overstates the case when it says
that this "keeps most of the benefit". As the numbers below show,
the split index file is small enough that skipping its hash saves
next to nothing, so with this patch index.skipHash has little effect
once a split index is in use.
That said, I do not think both can be kept without changing the index
format. Readers die() unless the "link" extension names the trailing
hash of the shared index, and a trailer that is neither null nor the
real hash makes "git fsck" fail. So a shared index written without
its hash can only be called sharedindex.<null OID>, which is exactly
what goes wrong today. One of the two has to give.
> Stepping back a bit, isn't the expectation of splitIndex that these
> incremental modifications held in non-base index files are relatively
> small, thanks to the bulk of data that the base index file holds
> covering almost everything in the repository? In other words, isn't the
> use of splitIndex a strong sign that the base index file would benefit
> the most from skipHash? And this patch is breaking the skipHash feature
> for the use case that would benefit the most. And not hashing the index
> files that are not bases would not save as much, since they are expected
> to be much smaller.
Per write, yes. But what skipHash saves is the hashing done on each
write, and the shared index is only written when it is rewritten,
which the split index is designed to make rare. The frequent writes
are of the small split index, where, as you say, there is little to
save.
> I wonder if going in the other direction, i.e., when both are enabled,
> disabling splitIndex and working only on the base hash, would be an
> alternative that is equally viable as this change? Both will *break*
> the promise of one feature so that the result can live with the other
> feature. What are the pros and cons between them?
I see three ways to resolve it when both are set:
1. disable the split index and keep skipHash (your suggestion),
2. keep the split index and ignore index.skipHash while it is in
use,
3. keep both, but always hash the shared index (this patch).
To compare them, I measured a repository with 100k files in 1,000
directories, index v4 (7.0MB) with the untracked cache enabled, so
that the split index carries the cache-tree and untracked cache
extensions as it would in practice. Each round changes K files and
runs "git add -u", "git commit", "git status" (after touching the
files), and "git checkout HEAD~1" and back. 1 and 2 are emulated by
turning the other setting off. The times are the index write and
read regions from trace2, median of 7 runs, averaged over add, commit
and status (Apple M4 Pro, SHA1DC):
index write (ms) index .git/index
K=1 K=100 K=10000 read K=1 / K=10000
neither 18.3 15.2 15.5 3 ms 7.0 / 7.0 MB
1: skipHash only 6.1 6.0 6.1 3 ms 7.0 / 7.0 MB
2: splitIndex only 0.4 0.4 1.9 3 ms 0.07 / 0.75 MB
3: both, this patch 0.3 0.3 0.9 3 ms 0.07 / 0.75 MB
Rewriting the whole index takes 15-20ms with neither feature and 6ms
with skipHash; rewriting the shared index takes 15-22ms with 2 or 3,
as both hash it. The checkout round trip, which writes the index
twice, shows the same pattern.
- The write time hardly depends on K: without a split index every
write covers all entries, and with one the split index stays small
(0.75MB at K=10000). No K up to 10000 (10% of the entries) made 2
or 3 rewrite the shared index; that takes new or re-created entries
beyond splitIndex.maxPercentChange (20% by default), e.g. when
checking out a distant branch.
- 1 cuts each write from ~15-18ms to ~6ms. 2 cuts it to under 2ms,
but pays ~10-15ms more than 1 whenever it rewrites the shared
index, so it comes out ahead unless about one write in three does
so.
- 3 differs from 2 only in hashing .git/index, which costs ~0.1ms
for 0.07MB and ~1ms for 0.75MB here. That is all index.skipHash
can still save with a split index.
- The index read time is the same ~3ms in all four.
- At this size, all of this is small next to the run times of the
commands (110ms to 3.8s), which are dominated by the work on the
files themselves, and the differences there are mostly within the
noise.
Performance aside, the two settings do not come from symmetric
places, which matters for 1:
- index.skipHash is only ever a configuration variable: it is either
implied by feature.manyFiles, or set as index.skipHash, by the user
or by Scalar, which writes index.skipHash=true into the repository
configuration and resets it on "scalar reconfigure".
- The split index is enabled by core.splitIndex, which neither a
feature.* setting nor Scalar sets, or by "git update-index
--split-index", which stays in effect while core.splitIndex is
unset.
When both are set in the configuration, there is no telling which one
the user cares about more. But 1 would let a default implied by
feature.manyFiles override an explicit core.splitIndex, although
feature.* is documented to only change defaults. For "git
update-index --split-index", 1 would either have to let a
configuration variable override a command line option, whereas today
the option still takes effect, with a warning, when core.splitIndex
is false, or honor the option for that write, which needs the change
in this patch anyway. And in a Scalar enlistment, core.splitIndex
would only work after setting index.skipHash=false, and would stop
working again at the next "scalar reconfigure". There is also
precedent for the split index taking priority: the sparse index is
not written while a split index is in use (see
is_sparse_index_allowed()).
Between 2 and 3 the performance is practically the same, so it comes
down to principle. 3 deviates from the configuration only where the
index format forces it to. 2 is simpler to explain ("index.skipHash
has no effect with a split index") and keeps the checksum of
.git/index, at the cost of ignoring a setting it does not strictly
need to ignore. I lean towards 3, but would be happy to switch to 2
if you prefer the simpler rule; the difference is a single condition.
Once we settle on the direction, I will send a v2 with the log
message and documentation updated accordingly.
Thanks.
Technical Details
Message-ID:
<5dfa732c.94b8.1a21d16a974.Coremail.bupt_xingxin@163.com>Path:
mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76511-linux-kernel-git=dewy.ruReferences:
<pull.2337.git.1795701443098.gitgitgadget@gmail.com> <xmqqld6fjt55.fsf@gitster.g>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76511-linux-kernel-git=dewy.ru
From: bupt_xingxin@163.com ("Xing Xin")
Newsgroups: linux.kernel.git
Subject: Re:Re: [PATCH] read-cache: hash the shared index even with
index.skipHash
Date: Fri, 27 Nov 2026 20:59:14 +0800 (CST)
Organization: Usenet Network
Message-ID: <5dfa732c.94b8.1a21d16a974.Coremail.bupt_xingxin@163.com>
References: <pull.2337.git.1795701443098.gitgitgadget@gmail.com>
<xmqqld6fjt55.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain; charset=GBK
Content-Transfer-Encoding: base64
Injection-Info: usenet.network;
logging-data="733341"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:jEpeqNKOXSkUR0ZJEiwakkGbyV8= sha256:FRBGP384mnJ1/t/iAUcyC1vqu5gQwtQ6+lMW3V+HvA0=
sha1:Y+DEzCqbjBY2/qMN5WfhvMHcpiQ= sha256:C6ryMwS84LcHCxBxqGEj8QaspubP2dONv23hQCbGyI4=
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 03D5D125F53; Fri, 27 Nov 2026 16:00:00 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.949
X-Spam-Status: No, score=-1.949 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, 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 (1024-bit key)
header.d=163.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 i3upPE7AZ2SD;
Fri, 27 Nov 2026 15:59:56 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-76511-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id B6F45125F48; Fri, 27 Nov 2026 15:59:47 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 3A54C26501; Fri, 27 Nov 2026 12:59:46 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1795784383;
b=19V/Etbe7VLgzHzY/4lsAVpRMkiF/GEUhHDUdCgwWXIERuy8X6ZcYHpzkUnWdkhA43HD
I5yC5Ub92pkYe0NnmzaOvrp/3h6LUKmRDW6RyidslhVbDXjqDpi1sufXlfmqqHH7UbVpC
RWMI0UA476gHyRoRyoed0Rn9FpyvMrDsX92sOQEQDNIlTViKxRbsuJZHlG9wWCsZJgNEv
Az0Uz8VNqc994i9lnCwPdAClRfmhMzPXaHUlMLahCCSKWZcwtqxpWkSS9vZjzP6fcEDhC
Xr0HJfvmFst+yA4pz8cNVCAKXLW+RIieEANTWN6mf/1n46+9qyGm9fyksLkA3m7WlLQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795784383;
h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Date:From:To:Cc:
Subject:X-Priority:X-Mailer:In-Reply-To:References:X-NTES-SC:
Content-Transfer-Encoding:Content-Type:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Message-ID:X-Coremail-Locale:X-CM-TRANSID:
X-CM-SenderInfo:X-Coremail-Antispam;
bh=0N5nNbNvUBfacYHTY8G3kbtsAxr5nwxKfsxWw4LuyrQ=;
b=HTsPqo21ox6iCa4i+4NTUMJzBPvTPerxAglLz+lfVevQP/A1QotWFWKYJderWdDY2D7b
o2XNyuohIr7huP7FA72QCAKAEe3HPTH8eiRKZLMBJrvp6Iq/sJYMQYhC5vGA60Qb7wYTs
Kel6hhj+WhpM7iRmQB57qw1HVAn0Uu6UcUumP0pJruvU7D9IS0rfXgcFrA9j1el+byEnp
eH0Amj1zLbQD+lknCqD/w1eUiiNCURJctQh+XtuOQR20oc6c7K1/3uDppy5NUvDX61J3g
QIUnISznDrcsmfed6tOUQwfm31RKi/rlW+k20YOJxFxQIR3DrKGIW6ignGiDe2JhsIA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=DJMkFt1A;
dmarc=pass header.from=163.com;
spf=pass smtp.mailfrom=163.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 8E7F9606A326;
Fri, 27 Nov 2026 12:59:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=DJMkFt1A
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.4
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795784382;
b=D8YoXkZSh/V+i4XuF5ZAnXqG18GToO3onFWVfqLHFNTH8GdLv8jMuj+xt4/C4cm/WIzU
XXrl0iYlDR3BvCEMF2QMrXvgXrpV966OxOMlPt90eXTdq29QX2EjSfodshUgJp/4e8aTz
vHzfFK6lDgri141Is8nkIv6PQexohMIUgHyZAZc0U8Yk+cngcMiv1m47hvnsLnkRyP/uo
l37SYCYBvH7LP3jB5JRPqBkPQHE4LCpI4ryG4mdOYvRanNPzLf6porxD5V1F7RfgWj1jx
ps5e/l8tyl5NbPuCKpXXoWFCybX9FTLy1v1VBejLkxPecJXrCvrwOGQm2z+gqhaMWUg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795784382;
h=DMARC-Filter:DKIM-Signature:Date:From:To:Cc:Subject:X-Priority:
X-Mailer:In-Reply-To:References:X-NTES-SC:Content-Transfer-Encoding:
Content-Type:MIME-Version:Message-ID:X-Coremail-Locale:X-CM-TRANSID:
X-CM-SenderInfo:X-Coremail-Antispam;
bh=0N5nNbNvUBfacYHTY8G3kbtsAxr5nwxKfsxWw4LuyrQ=;
b=KvY5NU1V8InIfAW9J3gmH4La2Oy0AV5UT3ACp6chorBh2fkIsd7BDSs8cu8rd0YliR8x
gyNFVOai/viI7ZKpBdNVPGvBmqHr8s814nVoi6f8C5ZQsYsFwQU3C0P8SkmPKRcZ5B7pf
Etl6ksbWyiEjNxrLXAjmy7FyknWGLjwu9XmRe/7rsFb+KFe7O9cvK/CPwotImJz3yrdms
2NGPw+Rkm6zpHuEYCaVC0Z0wdmvvtZjgxgq+9TC++pC2/H4K5cbnd3VolAh2IaiPSgv03
ZkDlHYo34mnutQssdETVi0uHAYdrsH0VTUQllnHR5XhxqAOohDQiWkXXLBkveDLrX/g==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=163.com;
spf=pass smtp.mailfrom=163.com;
dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=DJMkFt1A;
arc=none smtp.remote-ip=117.135.210.4
X-Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.4])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81021606A31C
for <git@vger.kernel.org>; Fri, 27 Nov 2026 12:59:40 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 81021606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com;
s=s110527; h=Date:From:To:Subject:Content-Type:MIME-Version:
Message-ID; bh=0N5nNbNvUBfacYHTY8G3kbtsAxr5nwxKfsxWw4LuyrQ=; b=D
JMkFt1ArProDpC+pyimuN3mB8aUEONl6/q4S4jxvye5TUsvAym4N9LFLB2y33izp
0s3h2JVtR56RwCISXpWaDfhgm3J9UOwUjNCRXrIbwJV8H14BiLB0Nq5vtWs5srtl
kHqru5+MnbMnWtlmN+Rfiz8Ptl45+qBcdzvNBX0n1g=
X-Cc: "blanet via GitGitGadget" <gitgitgadget@gmail.com>, git@vger.kernel.org,
"Xing Xin" <xingxin.xx@bytedance.com>
X-Priority: 3
X-Mailer: Coremail Webmail Server Version 2023.4-cmXT build
20260511(2e539873) Copyright (c) 2002-2026 www.mailtech.cn 163com
X-In-Reply-To: <xmqqld6fjt55.fsf@gitster.g>
X-NTES-SC: AL_Qu2SB/uTu0su4iGdY+kfmU4Xg+42Xsa1uf4n3oNUPJ94jArp2ysnRV1FOmLV6+asGQKigAm3TyZg6sllYblhQ6glis9WFxyBGBErjyU3/ICQow==
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-Coremail-Locale: zh_CN
X-CM-TRANSID: eSgvCgD3t0ajfglr66J3AA--.1226W
X-CM-SenderInfo: xexs3sp0lqw5llq6il2tof0z/xtbCzQPkUmsJfqP2pQAA3U
X-Coremail-Antispam: 1U5529EdanIXcx71UUUUU7vcSsGvfC2KfnxnUU==