git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2alt/2] dir: match "attr" pathspec magic with correct paths

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 9, 2023, 09:28 UTC
Message-ID
<xmqqzg454eoc.fsf@gitster.g>
In-Reply-To
<39d5e14d-f2e9-e619-c3e8-e63c7547370b@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 23 quoted lines
>> This "common leading prefix" optimization has two main features:
>>
>>  * discard the entries in the in-core index that are outside of the
>>    common leading prefix; if you are doing "ls-files one/a one/b",
>>    we know all matches must be from "one/", so first the code
>>    discards all entries outside the "one/" directory from the
>>    in-core index.  This allows us to work on a smaller dataset.
>>
>>  * allow skipping the comparison of the leading bytes when matching
>>    pathspec with path.  When "ls-files" finds the path "one/a/1" in
>>    the in-core index given "one/a" and "one/b" as the pathspec,
>>    knowing that common leading prefix "one/" was found lets the
>>    pathspec matchinery not to bother comparing "one/" part, and
>>    allows it to feed "a/1" down, as long as the pathspec element
>>    "one/a" gets corresponding adjustment to "a".
>> ...
> With your big patch 2:
> ...
> The difference to main is small enough to get lost in the noise.
>
> The one-line fix is nice and surgical, but I like the other one more.
> Gets rid of crusty underutilized code that doesn't even seem to make
> a measurable difference.

Your benchmark matches my intuition, in that the main benefit of the optimization comes from discarding the in-core cache entries outside the area covered by the common prefix, and not from being able to skip comparing a leading bytes. The value in code simplification the larger change has may want to be pursued later, but I'd rather see us make a small "fix" that can be merged down to 'maint' first.

Thanks.
Previous: René ScharfeNext: René Scharfe
Message 7 of 9 in “Fix attr magic combined with pathspec prefix”
  1. 0/2 Fix attr magic combined with pathspec prefixJunio C Hamano, Jul 7, 2023
  2. 2/2 dir: do not feed path suffix to pathspec matchJunio C Hamano, Jul 7, 2023
  3. dir: do not feed path suffix to pathspec matchJunio C Hamano, Jul 7, 2023
  4. René ScharfeJul 8, 2023
  5. dir: match "attr" pathspec magic with correct pathsJunio C Hamano, Jul 8, 2023
  6. René ScharfeJul 9, 2023
  7. Junio C HamanoJul 9, 2023
  8. René ScharfeJul 8, 2023
  9. 1/2 t6135: attr magic with path patternJunio C Hamano, Jul 7, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.