fsmonitor: optimize processing of directory events
commit95a4e78a746be2b87972c03c82e8b1fe8fe0bea1
authorJeff Hostetler <jeffhost@microsoft.com>
Thu, 26 May 2022 21:47:14 +0000 (26 21:47 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 26 May 2022 22:59:27 +0000 (26 15:59 -0700)
treee855ac23dcd36a138c465c1a281fd8967d8a8028
parentde7e0b58ea4bb1ca8242e677096dae50f96e9b7e
fsmonitor: optimize processing of directory events

Teach Git to perform binary search over the cache-entries for a directory
notification and then linearly scan forward to find the immediate children.

Previously, when the FSMonitor reported a modified directory Git would
perform a linear search on the entire cache-entry array for all
entries matching that directory prefix and invalidate them.  Since the
cache-entry array is already sorted, we can use a binary search to
find the first matching entry and then only linearly walk forward and
invalidate entries until the prefix changes.

Also, the original code would invalidate anything having the same
directory prefix.  Since a directory event should only be received for
items that are immediately within the directory (and not within
sub-directories of it), only invalidate those entries and not the
whole subtree.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fsmonitor.c