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

[PATCH v3 0/7] use fsmonitor data in git diff eliminating O(num_files) calls to lstat

From
Nipunn Koorapati via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 19, 2020, 22:47 UTC
Message-ID
<pull.756.v3.git.1603147657.gitgitgadget@gmail.com>
In-Reply-To
<pull.756.v2.git.1603143316.gitgitgadget@gmail.com>

Credit to alexmv who made this commit back in Dec, 2017 when he was at dbx. I've rebased it and am submitting it now.

With fsmonitor enabled, git diff currently lstats every file in the repo This makes use of the fsmonitor extension to skip lstat() calls on files that fsmonitor judged as unmodified.

I was able to do some testing with/without this change in a large in-house repo (~ 400k files).

----------------------------------------- (1) With fsmonitor enabled - on master of git (2.29.0) ----------------------------------------- ../git/bin-wrappers/git checkout HEAD~200 strace -c ../git/bin-wrappers/git diff

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 99.64    4.358994          10    446257         3 lstat
  0.12    0.005353           7       764       360 open

(A subsequent call) strace -c ../git/bin-wrappers/git diff

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 99.84    4.380955          10    444904         3 lstat
  0.06    0.002564         135        19           munmap
...

----------------------------------------- (2) With fsmonitor enabled - with my patch ----------------------------------------- ../git/bin-wrappers/git checkout HEAD~200 strace -c ../git/bin-wrappers/git diff

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 50.72    0.003090         163        19           munmap
 19.63    0.001196         598         2           futex
...
  0.00    0.000000           0         4         3 lstat

----------------------------------------- (3) With fsmonitor disabled entirely -----------------------------------------

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 98.52    0.277085       92362         3           futex
  0.27    0.000752           4       191        63 open
...
  0.14    0.000397           3       158         3 lstat
I was able to encode this into a perf test in one of the commits.
Changes since Patch Series V1
 * Add git diff -- <pathspec> to perf tests
 * improve readability of bitwise ops
Alex Vandiver (1):
  fsmonitor: use fsmonitor data in `git diff`
Nipunn Koorapati (6):
  t/perf/README: elaborate on output format
  t/perf/p7519-fsmonitor.sh: warm cache on first git status
  t/perf: add fsmonitor perf test for git diff
  perf lint: check test-lint-shell-syntax in perf tests
  p7519-fsmonitor: refactor to avoid code duplication
  p7519-fsmonitor: add a git add benchmark
 diff-lib.c                | 15 +++++-
 t/Makefile                |  3 +-
 t/perf/README             |  2 +
 t/perf/p3400-rebase.sh    |  6 +--
 t/perf/p7519-fsmonitor.sh | 96 ++++++++++++++++++++++-----------------
 5 files changed, 75 insertions(+), 47 deletions(-)
base-commit: d4a392452e292ff924e79ec8458611c0f679d6d4
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-756%2Fnipunn1313%2Fdiff_fsmon-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-756/nipunn1313/diff_fsmon-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/756
Range-diff vs v2:
 1:  cba03dd40b = 1:  cba03dd40b fsmonitor: use fsmonitor data in `git diff`
 2:  1c7876166f = 2:  1c7876166f t/perf/README: elaborate on output format
 3:  401f696c81 = 3:  401f696c81 t/perf/p7519-fsmonitor.sh: warm cache on first git status
 4:  f572e226bb ! 4:  b3ad8faac4 t/perf: add fsmonitor perf test for git diff
     @@ t/perf/p7519-fsmonitor.sh: test_expect_success "setup for fsmonitor" '
       	git config core.fsmonitor "$INTEGRATION_SCRIPT" &&
       	git update-index --fsmonitor &&
      +	mkdir 1_file 10_files 100_files 1000_files 10000_files &&
     -+	for i in `seq 1 10`; do touch 10_files/$i; done &&
     -+	for i in `seq 1 100`; do touch 100_files/$i; done &&
     -+	for i in `seq 1 1000`; do touch 1000_files/$i; done &&
     -+	for i in `seq 1 10000`; do touch 10000_files/$i; done &&
     ++	for i in $(test_seq 1 10); do touch 10_files/$i; done &&
     ++	for i in $(test_seq 1 100); do touch 100_files/$i; done &&
     ++	for i in $(test_seq 1 1000); do touch 1000_files/$i; done &&
     ++	for i in $(test_seq 1 10000); do touch 10000_files/$i; done &&
      +	git add 1_file 10_files 100_files 1000_files 10000_files &&
      +	git commit -m "Add files" &&
       	git status  # Warm caches
 -:  ---------- > 5:  28c1e488bf perf lint: check test-lint-shell-syntax in perf tests
 -:  ---------- > 6:  b38f2984f9 p7519-fsmonitor: refactor to avoid code duplication
 -:  ---------- > 7:  d392a523f2 p7519-fsmonitor: add a git add benchmark
-- 
gitgitgadget
Previous: Nipunn KoorapatiNext: Nipunn Koorapati via GitGitGadget
Message 26 of 52 in “use fsmonitor data in git diff eliminating O(num_files) calls to lstat”
  1. 0/4 use fsmonitor data in git diff eliminating O(num_files) calls to lstatNipunn Koorapati via GitGitGadget, Oct 17, 2020
  2. 1/4 fsmonitor: use fsmonitor data in `git diff`Alex Vandiver via GitGitGadget, Oct 17, 2020
  3. Junio C HamanoOct 17, 2020
  4. Nipunn KoorapatiOct 18, 2020
  5. Taylor BlauOct 18, 2020
  6. Junio C HamanoOct 18, 2020
  7. Taylor BlauOct 18, 2020
  8. Junio C HamanoOct 19, 2020
  9. Taylor BlauOct 19, 2020
  10. Nipunn KoorapatiOct 19, 2020
  11. 2/4 t/perf/README: elaborate on output formatNipunn Koorapati via GitGitGadget, Oct 17, 2020
  12. 4/4 t/perf: add fsmonitor perf test for git diffNipunn Koorapati via GitGitGadget, Oct 17, 2020
  13. Junio C HamanoOct 17, 2020
  14. 3/4 t/perf/p7519-fsmonitor.sh: warm cache on first git statusNipunn Koorapati via GitGitGadget, Oct 17, 2020
  15. Taylor BlauOct 18, 2020
  16. 0/4 use fsmonitor data in git diff eliminating O(num_files) calls to lstatNipunn Koorapati via GitGitGadget, Oct 19, 2020
  17. 1/4 fsmonitor: use fsmonitor data in `git diff`Alex Vandiver via GitGitGadget, Oct 19, 2020
  18. 2/4 t/perf/README: elaborate on output formatNipunn Koorapati via GitGitGadget, Oct 19, 2020
  19. 3/4 t/perf/p7519-fsmonitor.sh: warm cache on first git statusNipunn Koorapati via GitGitGadget, Oct 19, 2020
  20. 4/4 t/perf: add fsmonitor perf test for git diffNipunn Koorapati via GitGitGadget, Oct 19, 2020
  21. Taylor BlauOct 19, 2020
  22. Taylor BlauOct 19, 2020
  23. Nipunn KoorapatiOct 19, 2020
  24. Taylor BlauOct 19, 2020
  25. Nipunn KoorapatiOct 19, 2020
  26. 0/7 use fsmonitor data in git diff eliminating O(num_files) calls to lstatNipunn Koorapati via GitGitGadget, Oct 19, 2020
  27. 3/7 t/perf/p7519-fsmonitor.sh: warm cache on first git statusNipunn Koorapati via GitGitGadget, Oct 19, 2020
  28. 1/7 fsmonitor: use fsmonitor data in `git diff`Alex Vandiver via GitGitGadget, Oct 19, 2020
  29. 2/7 t/perf/README: elaborate on output formatNipunn Koorapati via GitGitGadget, Oct 19, 2020
  30. 5/7 perf lint: check test-lint-shell-syntax in perf testsNipunn Koorapati via GitGitGadget, Oct 19, 2020
  31. Taylor BlauOct 20, 2020
  32. Junio C HamanoOct 20, 2020
  33. Taylor BlauOct 20, 2020
  34. Nipunn KoorapatiOct 20, 2020
  35. Nipunn KoorapatiOct 20, 2020
  36. 7/7 p7519-fsmonitor: add a git add benchmarkNipunn Koorapati via GitGitGadget, Oct 19, 2020
  37. Nipunn KoorapatiOct 19, 2020
  38. Taylor BlauOct 20, 2020
  39. 4/7 t/perf: add fsmonitor perf test for git diffNipunn Koorapati via GitGitGadget, Oct 19, 2020
  40. 6/7 p7519-fsmonitor: refactor to avoid code duplicationNipunn Koorapati via GitGitGadget, Oct 19, 2020
  41. Taylor BlauOct 20, 2020
  42. 0/7 use fsmonitor data in git diff eliminating O(num_files) calls to lstatNipunn Koorapati via GitGitGadget, Oct 20, 2020
  43. 1/7 fsmonitor: use fsmonitor data in `git diff`Alex Vandiver via GitGitGadget, Oct 20, 2020
  44. 2/7 t/perf/README: elaborate on output formatNipunn Koorapati via GitGitGadget, Oct 20, 2020
  45. 6/7 p7519-fsmonitor: refactor to avoid code duplicationNipunn Koorapati via GitGitGadget, Oct 20, 2020
  46. 3/7 t/perf/p7519-fsmonitor.sh: warm cache on first git statusNipunn Koorapati via GitGitGadget, Oct 20, 2020
  47. 5/7 perf lint: add make test-lint to perf testsNipunn Koorapati via GitGitGadget, Oct 20, 2020
  48. Taylor BlauOct 20, 2020
  49. Nipunn KoorapatiOct 20, 2020
  50. Taylor BlauOct 20, 2020
  51. 4/7 t/perf: add fsmonitor perf test for git diffNipunn Koorapati via GitGitGadget, Oct 20, 2020
  52. 7/7 p7519-fsmonitor: add a git add benchmarkNipunn Koorapati via GitGitGadget, Oct 20, 2020

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.