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

[PATCH 0/4] Performance improvement & cleanup in loose ref iteration

From
Victoria Dye via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 6, 2023, 18:09 UTC
Message-ID
<pull.1594.git.1696615769.gitgitgadget@gmail.com>

While investigating ref iteration performance in builtins like 'for-each-ref' and 'show-ref', I found two small improvement opportunities.

The first patch tweaks the logic around prefix matching in 'cache_ref_iterator_advance' so that we correctly skip refs that do not actually match a given prefix. The unnecessary iteration doesn't seem to be causing any bugs in the ref iteration commands that I've tested, but it doesn't hurt to be more precise (and it helps with some other patches I'm working on ;) ).

The next three patches update how 'loose_fill_ref_dir' determines the type of ref cache entry to create (directory or regular). On platforms that include d_type information in 'struct dirent' (as far as I can tell, all except NonStop & certain versions of Cygwin), this allows us to skip calling 'stat'. In ad-hoc testing, this improved performance of 'git for-each-ref' by about 20%.

Thanks!
 * Victoria
Victoria Dye (4):
  ref-cache.c: fix prefix matching in ref iteration
  dir.[ch]: expose 'get_dtype'
  dir.[ch]: add 'follow_symlink' arg to 'get_dtype'
  files-backend.c: avoid stat in 'loose_fill_ref_dir'
 diagnose.c           | 42 +++---------------------------------------
 dir.c                | 33 +++++++++++++++++++++++++++++++++
 dir.h                | 16 ++++++++++++++++
 refs/files-backend.c | 14 +++++---------
 refs/ref-cache.c     |  3 ++-
 5 files changed, 59 insertions(+), 49 deletions(-)
base-commit: 3a06386e314565108ad56a9bdb8f7b80ac52fb69
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1594%2Fvdye%2Fvdye%2Fref-iteration-cleanup-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1594/vdye/vdye/ref-iteration-cleanup-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1594
-- 
gitgitgadget
Next: Victoria Dye via GitGitGadget
Message 1 of 21 in “Performance improvement & cleanup in loose ref iteration”
  1. 0/4 Performance improvement & cleanup in loose ref iterationVictoria Dye via GitGitGadget, Oct 6, 2023
  2. 1/4 ref-cache.c: fix prefix matching in ref iterationVictoria Dye via GitGitGadget, Oct 6, 2023
  3. Junio C HamanoOct 6, 2023
  4. Patrick SteinhardtOct 9, 2023
  5. Victoria DyeOct 9, 2023
  6. Junio C HamanoOct 9, 2023
  7. 3/4 dir.[ch]: add 'follow_symlink' arg to 'get_dtype'Victoria Dye via GitGitGadget, Oct 6, 2023
  8. 2/4 dir.[ch]: expose 'get_dtype'Victoria Dye via GitGitGadget, Oct 6, 2023
  9. Junio C HamanoOct 6, 2023
  10. 4/4 files-backend.c: avoid stat in 'loose_fill_ref_dir'Victoria Dye via GitGitGadget, Oct 6, 2023
  11. Junio C HamanoOct 6, 2023
  12. Junio C HamanoOct 6, 2023
  13. Patrick SteinhardtOct 9, 2023
  14. Victoria DyeOct 9, 2023
  15. Patrick SteinhardtOct 10, 2023
  16. 0/4 Performance improvement & cleanup in loose ref iterationVictoria Dye via GitGitGadget, Oct 9, 2023
  17. 1/4 ref-cache.c: fix prefix matching in ref iterationVictoria Dye via GitGitGadget, Oct 9, 2023
  18. Patrick SteinhardtOct 10, 2023
  19. 2/4 dir.[ch]: expose 'get_dtype'Victoria Dye via GitGitGadget, Oct 9, 2023
  20. 3/4 dir.[ch]: add 'follow_symlink' arg to 'get_dtype'Victoria Dye via GitGitGadget, Oct 9, 2023
  21. 4/4 files-backend.c: avoid stat in 'loose_fill_ref_dir'Victoria Dye via GitGitGadget, Oct 9, 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.