Re: [PATCH v6 1/1] builtin/grep.c: integrate with sparse index
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 23, 2022, 16:40 UTC
- Message-ID
- <xmqq7d1uvybx.fsf@gitster.g>
- In-Reply-To
- <20220923041842.27817-2-shaoxuan.yuan02@gmail.com>
Shaoxuan Yuan <shaoxuan.yuan02@gmail.com> writes:
Show 11 quoted lines
> - Command used for testing: > > git grep --cached bogus -- "f2/f1/f1/*" > > The reason for specifying a pathspec is that, if we don't specify a > pathspec, then grep_tree() will walk all the trees and blobs to find the > pattern, and the time consumed doing so is not too different from using > the original ensure_full_index() method, which also spends most of the > time walking trees. However, when a pathspec is specified, this latest > logic will only walk the area of trees enclosed by the pathspec, and the > time consumed is reasonably a lot less.
Good. So without pathspec, we lazily populate the index and catch matches even from outside the sparse cone. We punt to "implicitly" apply the sparse cone(s) as a pathspec that limits the hits to the paths in the sparse cone(s).
> That is, if we don't specify a pathspec, the performance difference [1] > is indistinguishable: both methods walk all the trees and take generally > same amount of time (even with the index construction time included for > ensure_full_index()).
Good.