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

[PATCH WIP 0/3] top-level gitignore considered less harmful

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
May 26, 2012, 12:31 UTC
Message-ID
<1338035474-4346-1-git-send-email-pclouds@gmail.com>

While my mind is still fresh on exclude stuff, let's do something to improve the big top-level gitignore situation [1].

The last patch is the real meat, where it assumes caller calls it on a series of pathnames of the same dirname. It'll cache strcmp result of the dirname part so we only pay the cost once per pattern for all entries in the same directory.

The result is not so impressive (i'm on -O0 though). Old webkit.git, before:

real 0m6.418s user 0m5.561s sys 0m0.827s

after:

real 0m5.262s user 0m4.407s sys 0m0.850s

We could approach the problem a different way instead: push back as much dirname as possible back to "(struct exclude*)->base", but I'm afraid that may mess thing up with all the pushing/popping in prep_exclude.

Also about that, we should not need to call prep_exclude() on every pathname, at least when the caller is {fill,read}_directory().

There's another optimaztion we could do to pay even less. If users sort the exclude patterns, if we check dirname of one pattern and the next pattern shares the same dirname, skip comparing what we have compared again.

The same can be done on "base" (even easier because we can just compare base pointer to know if they are the same) but "base" is for non-top-level gitignore.

[1] http://thread.gmane.org/gmane.comp.version-control.git/194294
Nguyễn Thái Ngọc Duy (3):
  Unindent excluded_from_list()
  exclude: do strcmp as much as possible before fnmatch
  exclude: reduce computation cost on checking dirname in patterns
 dir.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++--------------------
 dir.h |   5 +-
 2 files changed, 120 insertions(+), 51 deletions(-)
-- 
1.7.10.2.549.g9354186
Next: Nguyễn Thái Ngọc Duy
Message 1 of 14 in “top-level gitignore considered less harmful”
  1. 0/3 top-level gitignore considered less harmfulNguyễn Thái Ngọc Duy, May 26, 2012
  2. 1/3 Unindent excluded_from_list()Nguyễn Thái Ngọc Duy, May 26, 2012
  3. 2/3 exclude: do strcmp as much as possible before fnmatchNguyễn Thái Ngọc Duy, May 26, 2012
  4. Junio C HamanoMay 27, 2012
  5. Nguyen Thai Ngoc DuyMay 27, 2012
  6. Junio C HamanoMay 27, 2012
  7. Nguyen Thai Ngoc DuyMay 28, 2012
  8. Junio C HamanoMay 28, 2012
  9. Junio C HamanoMay 29, 2012
  10. Thiago FarinaMay 29, 2012
  11. 3/3 exclude: reduce computation cost on checking dirname in patternsNguyễn Thái Ngọc Duy, May 26, 2012
  12. Nguyen Thai Ngoc DuyMay 26, 2012
  13. Jeff KingMay 26, 2012
  14. Nguyen Thai Ngoc DuyMay 27, 2012

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.