Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "blanet via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org,  blanet <bupt_xingxin@163.com>,
	 Xing Xin <xingxin.xx@bytedance.com>
Subject: Re: [PATCH v2] read-cache: hash the shared index even with index.skipHash
Date: Sat, 28 Nov 2026 13:41:01 -0800	[thread overview]
Message-ID: <xmqq7bhwvdle.fsf@gitster.g> (raw)
In-Reply-To: <pull.2337.v2.git.1795858039529.gitgitgadget@gmail.com> (blanet via GitGitGadget's message of "Sat, 28 Nov 2026 09:27:19 +0000")

"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
> ...
> 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.

The updated commit message explains both the failure mode and the
trade-off clearly, without overstating the savings on split-index
writes.

It is also worth checking how concurrent-update detection behaves when
both features are active.  Suppose a repository has both core.splitIndex
and index.skipHash enabled, and "git status" reads the split index and
later calls repo_verify_index() before writing back.

Because do_write_locked_index() still writes the split index with
skip_hash enabled, the split index has a null trailing hash on disk, and
merge_base_index() does not overwrite '.oid' or '.file_stat' on the main
index_state.  Thus verify_index_from() still sees a null '.oid' and
falls back to index_file_unchanged() on .git/index, so concurrent
updates are still detected correctly?  

Likewise, "git fsck" runs read_index_from() with verify_index_checksum
set, so verify_hdr() accepts the null trailer on .git/index while
verifying the real hash on the shared index file.

  reply	other threads:[~2026-11-28 21:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 13:57 [PATCH] read-cache: hash the shared index even with index.skipHash blanet via GitGitGadget
2026-11-26 19:21 ` Junio C Hamano
2026-11-27 12:59   ` Xing Xin
2026-11-27 18:44     ` Junio C Hamano
2026-11-28  9:27 ` [PATCH v2] " blanet via GitGitGadget
2026-11-28 21:41   ` Junio C Hamano [this message]
2026-11-30  7:47     ` Xing Xin

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=xmqq7bhwvdle.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=bupt_xingxin@163.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=xingxin.xx@bytedance.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