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

Re: [PATCH 1/4] fsmonitor: use fsmonitor data in `git diff`

From
Nipunn Koorapati <nipunn1313@gmail.com>
Date
Oct 18, 2020, 00:54 UTC
Message-ID
<CAN8Z4-W=+D-P_qCYijGMnStY-EGwKFx-+AYzjACDPAXnLRAA8A@mail.gmail.com>
In-Reply-To
<xmqqeelw8p8i.fsf@gitster.c.googlers.com>
> run_diff_files() is used not just by "git diff" but other things
> like "git add", so if we get an overall speed-up without having to
> pay undue cost, that would be a very good news.

Agreed! I may be able to write perf benchmark tests to highlight benefits to git add as well.

> 20% of the working tree, running refresh_fsmonitor() for the entire
> working tree is still a win, but if we are only checking less than
> that, we are better off without fsmonitor, or does a tradeoff like
> that exist?

My understanding is that refresh_fsmonitor is O(delta_since_last_refresh) - so for developers with large repositories - this cost will amortize out over subsequent commands, so I don't think it's worth investigating this tradeoff here. As a user of large repositories, I expect that my major source of fsmonitor activity to be user intent (eg git pull, or intentionally copying/editing a large number of files). After such a command, I expect my next git command to be slower - that would be unsurprising.

I think the tradeoff could be made for small diff requests, but I don't think it's worth adding complexity here - as that user will just have to pay the cost on their next git command.

> > +              *  eg - via git udpate-index --assume-unchanged
> > +              *  eg - via core.ignorestat=true
>
> ... what are these two lines doing here?

Intended to indicate potential ways that CE_VALID might be set. When I was reading the source here, it was pretty difficult to determine how this would be set. Agree that I picked unfortunate wording. Thanks for the suggestions. Will update in the next iteration.

Show 13 quoted lines
>
> would probably be what you meant bo say.
>
>         When CE_VALID is set (via "update-index --assume-unchanged"
>         or via adding paths while core.ignorestat is set to true),
>         the user has promised that the working tree file for that
>         path will not be modified.  When CE_FSMONITOR_VALID is true,
>         the fsmonitor knows that the path hasn't been modified since
>         we refreshed the cached stat information.  In either case,
>         we do not have to stat to see if the path has been removed
>         or modified.
>
> or something like that, perhaps.
Sounds good. Will clarify. I like your comment better as well.
Show 7 quoted lines
>
> > +              */
> > +             if (ce->ce_flags & CE_VALID || ce->ce_flags & CE_FSMONITOR_VALID) {
>
> Would it become easier to read, if written like this instead?
>
>                 if (ce->ce_flags & (CE_VALID | CE_FSMONITOR_VALID)) {

I personally find this more confusing because it involves multiple bitwise ops, but this is potentially due to me having more mental practice thinking about boolean operators vs bitwise operators. I'm more than happy to align with the common pattern of the repo. I'll change this.

>
> Thanks.
Thank you for the thorough review!
Previous: Junio C HamanoNext: Taylor Blau
Message 4 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.