Skip to content

read-cache: hash the shared index even with index.skipHash - #2337

Open
blanet wants to merge 1 commit into
gitgitgadget:masterfrom
blanet:xx/split-index-skip-hash
Open

blanet wants to merge 1 commit into
gitgitgadget:masterfrom
blanet:xx/split-index-skip-hash

Conversation

@blanet

@blanet blanet commented Nov 26, 2026

Copy link
Copy Markdown

No description provided.

@gitgitgadget

gitgitgadget Bot commented Nov 26, 2026

Copy link
Copy Markdown

There is an issue in commit 13fb6bb:
read-cache: hash the shared index even with index.skipHash

  • Commit not signed off

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 ee1f0c2 (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 hits a BUG() in
fsmonitor.c instead, as the fsmonitor bitmap refers to more entries
than the index has.

Scalar sets index.skipHash since 05f28e4 (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 05f28e4, in 7cce609 (t9210,
t9211: disable GIT_TEST_SPLIT_INDEX for scalar clone tests,
2026-04-15) and in a644ad5 (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. This keeps most of the
benefit: the shared index is rewritten only now and then (see
splitIndex.maxPercentChange), while the split index, written on every
index update, still skips it.

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>
@blanet
blanet force-pushed the xx/split-index-skip-hash branch from 13fb6bb to 0502560 Compare November 26, 2026 10:04
@blanet

blanet commented Nov 26, 2026

Copy link
Copy Markdown
Author

/submit

@gitgitgadget

gitgitgadget Bot commented Nov 26, 2026

Copy link
Copy Markdown

Submitted as pull.2337.git.1795701443098.gitgitgadget@gmail.com

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2337/blanet/xx/split-index-skip-hash-v1

To fetch this version to local tag pr-2337/blanet/xx/split-index-skip-hash-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2337/blanet/xx/split-index-skip-hash-v1

@gitgitgadget

gitgitgadget Bot commented Nov 26, 2026

Copy link
Copy Markdown

Junio C Hamano wrote on the Git mailing list (how to reply to this email):

"blanet via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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 hits a BUG() in
> fsmonitor.c instead, as the fsmonitor bitmap refers to more entries
> than the index has.

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.

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.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant