Patchwork fsmonitor: issue debug messages when we fall back to core status

login
register
mail settings
Submitter Boris Feld
Date Nov. 28, 2017, 8:30 p.m.
Message ID <1c6858cefe1701c27b45.1511901018@FB>
Download mbox | patch
Permalink /patch/25784/
State Accepted
Headers show

Comments

Boris Feld - Nov. 28, 2017, 8:30 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1511884854 18000
#      Tue Nov 28 11:00:54 2017 -0500
# Node ID 1c6858cefe1701c27b459c6b5647b7b023f229b5
# Parent  8287df8b7be545fdafa22b771012ac65f6264d12
# EXP-Topic fsmonitor-debug
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1c6858cefe17
fsmonitor: issue debug messages when we fall back to core status

Having more information about when and why fsmonitor bails out help when
looking into status performance.
Augie Fackler - Nov. 29, 2017, 10:47 p.m.
On Tue, Nov 28, 2017 at 03:30:18PM -0500, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1511884854 18000
> #      Tue Nov 28 11:00:54 2017 -0500
> # Node ID 1c6858cefe1701c27b459c6b5647b7b023f229b5
> # Parent  8287df8b7be545fdafa22b771012ac65f6264d12
> # EXP-Topic fsmonitor-debug
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1c6858cefe17
> fsmonitor: issue debug messages when we fall back to core status

queued, thanks

Patch

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -224,16 +224,21 @@  def overridewalk(orig, self, match, subr
     Whenever full is False, ignored is False, and the Watchman client is
     available, use Watchman combined with saved state to possibly return only a
     subset of files.'''
-    def bail():
+    def bail(reason):
+        self._ui.debug('fsmonitor: fallback to core status, %s\n' % reason)
         return orig(match, subrepos, unknown, ignored, full=True)
 
-    if full or ignored or not self._watchmanclient.available():
-        return bail()
+    if full:
+        return bail('full rewalk requested')
+    if ignored:
+        return bail('listing ignored files')
+    if not self._watchmanclient.available():
+        return bail('client unavailable')
     state = self._fsmonitorstate
     clock, ignorehash, notefiles = state.get()
     if not clock:
         if state.walk_on_invalidate:
-            return bail()
+            return bail('no clock')
         # Initial NULL clock value, see
         # https://facebook.github.io/watchman/docs/clockspec.html
         clock = 'c:0:0'
@@ -263,7 +268,7 @@  def overridewalk(orig, self, match, subr
         if _hashignore(ignore) != ignorehash and clock != 'c:0:0':
             # ignore list changed -- can't rely on Watchman state any more
             if state.walk_on_invalidate:
-                return bail()
+                return bail('ignore rules changed')
             notefiles = []
             clock = 'c:0:0'
     else:
@@ -338,7 +343,7 @@  def overridewalk(orig, self, match, subr
     except Exception as ex:
         _handleunavailable(self._ui, state, ex)
         self._watchmanclient.clearconnection()
-        return bail()
+        return bail('exception during run')
     else:
         # We need to propagate the last observed clock up so that we
         # can use it for our next query
@@ -346,7 +351,7 @@  def overridewalk(orig, self, match, subr
         if result['is_fresh_instance']:
             if state.walk_on_invalidate:
                 state.invalidate()
-                return bail()
+                return bail('fresh instance')
             fresh_instance = True
             # Ignore any prior noteable files from the state info
             notefiles = []