Skip to content

pr-2337/blanet/xx/split-index-skip-hash-v2

tagged this 28 Nov 09:27
From: Xing Xin <xingxin.xx@bytedance.com>

The shared index of a split index is named after its trailing hash,
which the split index records in its "link" extension to find it.
Since ee1f0c242e (read-cache: add index.skipHash config option,
2023-01-06), do_write_index() skips that hash for the shared index
too, so with index.skipHash and core.splitIndex both set, the shared
index is written as "sharedindex.<null OID>" and the split index
records a null OID as its base. Reading the index back, a null base
means there is no shared index: the entries that were moved there are
lost, "git ls-files" no longer shows them and "git status" reports
them as deleted and untracked. With fsmonitor, it can hit a BUG() in
fsmonitor.c instead, when the fsmonitor bitmap refers to more entries
than the index has.

Scalar has enabled index.skipHash since 05f28e4b3c (scalar: use
index.skipHash=true for performance, 2025-12-12), and
feature.manyFiles implies it. The tests that ran into this under
GIT_TEST_SPLIT_INDEX unset that variable instead, in 05f28e4b3c, in
7cce609e08 (t9210, t9211: disable GIT_TEST_SPLIT_INDEX for scalar
clone tests, 2026-04-15), and in 6b6d1d56eb (read-cache: verify
skipHash index by stat data, 2026-10-22) and a644ad5f34 (status: lock
the index only to write it, 2026-10-22).

Let the callers of do_write_index() decide whether to skip the hash,
and always compute it for the shared index, so that the two settings
no longer conflict.

This gives up index.skipHash on the file where skipping the hash would
save the most per write, as the shared index holds nearly all the
entries. But what index.skipHash saves is the hashing done on each
write, and the split index is designed to make writing a shared index
rare: once there is one, a new one is written only when more than
splitIndex.maxPercentChange of the entries (20% by default) are not
in it. The frequent writes are of the split index, which holds the
entries added or changed since the shared index was written, as well
as all the extensions, and still skips the hash.

Document this under index.skipHash, add a test, and drop the
workarounds, as those tests now pass with GIT_TEST_SPLIT_INDEX.

Signed-off-by: Xing Xin <xingxin.xx@bytedance.com>

Submitted-As: https://lore.kernel.org/git/pull.2337.v2.git.1795858039529.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2337.git.1795701443098.gitgitgadget@gmail.com
Assets 2
Loading