From: Phillip Wood Date: Wed, 14 May 2025 15:16:31 GMT Subject: Re: [PATCH 0/3] Integrate the sparse index with 'git apply' and 'git add -p/-i' Message-ID: In-Reply-To: Hi Stolee On 07/05/2025 01:55, Derrick Stolee via GitGitGadget wrote: > The sparse index helps make some Git commands faster when using > sparse-checkout in cone mode. However, not all code paths are aware that the > index can have non-blob entries, so we are careful about rolling this > feature out gradually. The cost of this rollout is that some commands are > slower with the sparse index as they need to expand a sparse index into a > full index in memory, which requires parsing tree objects to construct the > full path list. > > This patch series focuses on the 'git add -p' command, which is slow with > the sparse index for a couple of reasons, handled in the first two patches: > > 1. 'git add -p' uses 'git apply' as a subcommand and 'git apply' needs > integration with the sparse index. Luckily, we just need to add the repo > setting and appropriate tests to confirm it behaves as expected. > 2. The interactive modes of 'git add' ('-p' and '-i') leave cmd_add() > before the code that sets the repo setting to allow for a sparse index. > Patch 2 fixes this and adds appropriate tests to confirm the behavior in > a sparse-checkout. This made me wonder about the other commands that take "--patch" like checkout and reset. Do you know how well they handle the sparse index? They'll all benefit from the changes to git apply in this series but I was wondering if they need any further changes. Best Wishes Phillip > A third patch adds a performance test to p2000-sparse-operations.sh to > confirm that we are getting the performance improvement we expect: > > BASE PATCH 1 PATCH 2 > --------------------------------------------------------- > 2000.118: (full-v3) 0.80 0.84 +5.0% 0.84 +5.0% > 2000.119: (full-v4) 0.76 0.79 +3.9% 0.80 +5.3% > 2000.120: (sparse-v3) 2.09 1.39 -33.5% 0.07 -96.7% > 2000.121: (sparse-v4) 2.09 1.39 -33.5% 0.07 -96.7% > > > Thanks, -Stolee > > Derrick Stolee (3): > apply: integrate with the sparse index > git add: make -p/-i aware of sparse index > p2000: add performance test for 'git add -p' > > builtin/add.c | 7 +- > builtin/apply.c | 7 +- > t/perf/p2000-sparse-operations.sh | 1 + > t/t1092-sparse-checkout-compatibility.sh | 102 +++++++++++++++++++++++ > 4 files changed, 113 insertions(+), 4 deletions(-) > > > base-commit: 6c0bd1fc70efaf053abe4e57c976afdc72d15377 > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1914%2Fderrickstolee%2Fapply-sparse-index-v1 > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1914/derrickstolee/apply-sparse-index-v1 > Pull-Request: https://github.com/gitgitgadget/git/pull/1914