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

Re: [PATCH v2 5/6] fsmonitor: add documentation for the fsmonitor extension.

From
Ben Peart <peartben@gmail.com>
Date
May 22, 2017, 16:18 UTC
Message-ID
<5ab333a4-c3cd-1cb5-ba3e-6b08fa14c9e7@gmail.com>
In-Reply-To
<CACBZZX5URAeA+=12ezW-oDGnkdAqvQqV7it=HBaYCKUdx0p_XA@mail.gmail.com>
On 5/20/2017 8:10 AM, Ævar Arnfjörð Bjarmason wrote:
Show 32 quoted lines
>> +== File System Monitor cache
>> +
>> +  The file system monitor cache tracks files for which the query-fsmonitor
>> +  hook has told us about changes.  The signature for this extension is
>> +  { 'F', 'S', 'M', 'N' }.
>> +
>> +  The extension starts with
>> +
>> +  - 32-bit version number: the current supported version is 1.
>> +
>> +  - 64-bit time: the extension data reflects all changes through the given
>> +       time which is stored as the seconds elapsed since midnight, January 1, 1970.
>> +
>> +  - 32-bit bitmap size: the size of the CE_FSMONITOR_DIRTY bitmap.
>> +
>> +  - An ewah bitmap, the n-th bit indicates whether the n-th index entry
>> +    is CE_FSMONITOR_DIRTY.
>
> We already have a uint64_t in one place in the codebase (getnanotime)
> which uses a 64 bit time for nanosecond accuracy, and numerous
> filesystems already support nanosecond timestamps (ext4, that new
> Apple thingy...).
>
> I don't know if any of the inotify/fsmonitor APIs support that yet,
> but it seems inevitable that that'll be added if not, in some
> pathological cases we can have a lot of files modified in 1 second, so
> using nanosecond accuracy means there'll be a lot less data to
> consider in some cases.
>
> It does mean this'll only work until the year ~2500, but that seems
> like an acceptable trade-off.
>

I really don't think nano-second resolution is needed in this case for a few reasons.

The number of files that can change within a given second is limited by the IO throughput of the underlying device. Even assuming a very fast device and very small files and changes, this won't be that many files.

Without this patch, git would have scanned all those files every time. With this patch, git will only scan those files a 2nd time that are modified in the same second that it did the first scan *that came before the first scan started* (the "lots of files modified" section in the 1 second timeline below).

|------------------------- one second ---------------------|
|-lots of files modified - git status - more file modified-|

Yes, some duplicate status checks can be made but its still a significant win in any reasonable scenario. Especially when you consider that it is pretty unusual to do git status/add/commit calls in the middle of making lots of changes to files.

In addition, the backing file system monitor (Watchman) supports number of seconds since the unix epoch (unix time_t style). This means any support of nano seconds by git is academic until someone provides a file system watcher that does support nano second granularity.

Finally, the fsmonitor index extension is versioned so that we can seamlessly upgrade to nano second resolution later if we desire.

Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 18 of 30 in “Fast git status via a file system watcher”
  1. 0/6 Fast git status via a file system watcherBen Peart, May 18, 2017
  2. 1/6 bswap: add 64 bit endianness helper get_be64Ben Peart, May 18, 2017
  3. 2/6 dir: make lookup_untracked() available outside of dir.cBen Peart, May 18, 2017
  4. 3/6 fsmonitor: teach git to optionally utilize a file system monitor to speed up detecting new or changed files.Ben Peart, May 18, 2017
  5. Ben PeartMay 19, 2017
  6. Junio C HamanoMay 20, 2017
  7. Christian CouderMay 24, 2017
  8. 4/6 fsmonitor: add test cases for fsmonitor extensionBen Peart, May 18, 2017
  9. Torsten BögershausenMay 20, 2017
  10. 6/6 fsmonitor: add a sample query-fsmonitor hook script for WatchmanBen Peart, May 18, 2017
  11. Christian CouderMay 24, 2017
  12. Ævar Arnfjörð BjarmasonMay 26, 2017
  13. Ben PeartMay 26, 2017
  14. Ævar Arnfjörð BjarmasonMay 25, 2017
  15. 5/6 fsmonitor: add documentation for the fsmonitor extension.Ben Peart, May 18, 2017
  16. Junio C HamanoMay 20, 2017
  17. Ævar Arnfjörð BjarmasonMay 20, 2017
  18. Ben PeartMay 22, 2017
  19. Ævar Arnfjörð BjarmasonMay 22, 2017
  20. Ben PeartMay 25, 2017
  21. Christian CouderMay 24, 2017
  22. Ben PeartMay 25, 2017
  23. Christian CouderMay 27, 2017
  24. Ben PeartMay 30, 2017
  25. Christian CouderMay 30, 2017
  26. Ben PeartMay 30, 2017
  27. Christian CouderMay 31, 2017
  28. Christian CouderMay 31, 2017
  29. Ben PeartMay 31, 2017
  30. Ævar Arnfjörð BjarmasonMay 31, 2017

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.