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

Re: [PATCH/RFC v3 6/8] Add case insensitivity support when using git ls-files

From
Joshua Jensen <jjensen@workspacewhiz.com>
Date
Oct 4, 2010, 14:58 UTC
Message-ID
<4CA9EBA2.9020401@workspacewhiz.com>
In-Reply-To
<AANLkTikgLzczp1Gkmcg2v35oE2bKxBtxY389Z76FJDRz@mail.gmail.com>
  ----- Original Message -----
From: Erik Faye-Lund
Date: 10/4/2010 8:03 AM
Show 19 quoted lines
> On Mon, Oct 4, 2010 at 9:49 AM, Jonathan Nieder<jrnieder@gmail.com>  wrote:
>> Johannes Sixt wrote:
>>> On Sonntag, 3. Oktober 2010, Thomas Adam wrote:
>>>> It's a real shame about the code duplication here.  Can we not avoid
>>>> it just by doing:
>>>>
>>>> unsigned char c1 = (ignore_case) ? tolower(*match) : *match;
>>>> unisgned char c2 = (ignore_case) ? tolower(*name) : *name;
>>>>
>>>> I appreciate that to some it might look like perl golf, but...
>>> It has been discussed, and IIRC, the concensus was to keep the code
>>> duplication because this is an inner loop.
>> Did anyone time it?  If it really is not dwarfed by other computation,
>> then how about (warning: ugly!)
>>
> I believe it was timed. I was the one who reacted on this the first
> time around, and I seem to remember that the performance impact was
> indeed significant. This function is used all the time when updating
> the index etc IIRC.

In a good sized repository I have in front of me now, running 'git ls-files' through this code path results in 705,374 characters being processed by this body of code. Given the code listed above, that means we add 1,410,748 additional comparisons that everyone has to suffer through, even those on a case sensitive file system. Sure, the code could be optimized to not perform the double comparison, and the compiler may actually perform that optimization. Still, it is hundreds of thousands of additional comparisons and branches that were not there before.

I'm running on a really, really fast machine, a Xeon X5560. The difference in time for the above code versus what is in the patch seems to average about 0.07 seconds. Remember, this is an incredibly fast machine, and I imagine it will be worse on machines with slower processors and less cache.

As discussed in the original thread (which, I believe, was on the msysGit mailing list), one of Git's features is its speed. Maintaining that speed in the core.ignorecase=false case is top priority for me, but others with more know how can tell me I'm wrong.

Josh
Previous: Erik Faye-LundNext: Jonathan Nieder
Message 20 of 45 in “Extensions of core.ignorecase=true support”
  1. 0/6 Extensions of core.ignorecase=true supportJoshua Jensen, Oct 3, 2010
  2. 1/6 Add string comparison functions that respect the ignore_case variable.Joshua Jensen, Oct 3, 2010
  3. Ævar Arnfjörð BjarmasonOct 3, 2010
  4. Joshua JensenOct 3, 2010
  5. 0/8 ab/icase-directory: jj/icase-directory with Makefile + configure checksÆvar Arnfjörð Bjarmason, Oct 3, 2010
  6. 1/8 Makefile & configure: add a NO_FNMATCH flagÆvar Arnfjörð Bjarmason, Oct 3, 2010
  7. 2/8 Makefile & configure: add a NO_FNMATCH_CASEFOLD flagÆvar Arnfjörð Bjarmason, Oct 3, 2010
  8. Johannes SixtOct 3, 2010
  9. 2/8 Makefile & configure: add a NO_FNMATCH_CASEFOLD flagÆvar Arnfjörð Bjarmason, Oct 4, 2010
  10. 3/8 Add string comparison functions that respect the ignore_case variable.Ævar Arnfjörð Bjarmason, Oct 3, 2010
  11. 4/8 Case insensitivity support for .gitignore via core.ignorecaseÆvar Arnfjörð Bjarmason, Oct 3, 2010
  12. 5/8 Add case insensitivity support for directories when using git statusÆvar Arnfjörð Bjarmason, Oct 3, 2010
  13. 6/8 Add case insensitivity support when using git ls-filesÆvar Arnfjörð Bjarmason, Oct 3, 2010
  14. Thomas AdamOct 3, 2010
  15. Johannes SixtOct 3, 2010
  16. Thomas AdamOct 3, 2010
  17. Jonathan NiederOct 4, 2010
  18. Ævar Arnfjörð BjarmasonOct 4, 2010
  19. Erik Faye-LundOct 4, 2010
  20. Joshua JensenOct 4, 2010
  21. Jonathan NiederOct 4, 2010
  22. Robin RosenbergOct 4, 2010
  23. Ævar Arnfjörð BjarmasonOct 4, 2010
  24. Erik Faye-LundOct 4, 2010
  25. Joshua JensenOct 4, 2010
  26. Jonathan NiederOct 4, 2010
  27. Ævar Arnfjörð BjarmasonOct 4, 2010
  28. Johannes SixtOct 4, 2010
  29. Ævar Arnfjörð BjarmasonOct 4, 2010
  30. 7/8 Support case folding for git add when core.ignorecase=trueÆvar Arnfjörð Bjarmason, Oct 3, 2010
  31. 8/8 Support case folding in git fast-import when core.ignorecase=trueÆvar Arnfjörð Bjarmason, Oct 3, 2010
  32. Junio C HamanoOct 7, 2010
  33. Joshua JensenOct 7, 2010
  34. 2/6 Case insensitivity support for .gitignore via core.ignorecaseJoshua Jensen, Oct 3, 2010
  35. 3/6 Add case insensitivity support for directories when using git statusJoshua Jensen, Oct 3, 2010
  36. 4/6 Add case insensitivity support when using git ls-filesJoshua Jensen, Oct 3, 2010
  37. 5/6 Support case folding for git add when core.ignorecase=trueJoshua Jensen, Oct 3, 2010
  38. 6/6 Support case folding in git fast-import when core.ignorecase=trueJoshua Jensen, Oct 3, 2010
  39. Sverre RabbelierOct 3, 2010
  40. Johannes SixtOct 3, 2010
  41. Junio C HamanoOct 3, 2010
  42. Robert BuckOct 3, 2010
  43. Johannes SixtOct 3, 2010
  44. Robert BuckOct 6, 2010
  45. Joshua JensenOct 6, 2010

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.