D5588: watchman: disable fsmonitor when running non-interactively

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

D5588: watchman: disable fsmonitor when running non-interactively

pulkit (Pulkit Goyal)
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  One of the risks with activating fsmonitor globally is resource exhaustion
  (like inotify watches on Linux).
 
  When launching background-jobs, it's often better to not activate fsmonitor in
  order to conserve resources for future interactive commands launched by users.
 
  This can be overridden with the environment variable HGWATCHMAN_ENABLE

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5588

AFFECTED FILES
  hgext/fsmonitor/__init__.py

CHANGE DETAILS

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -777,6 +777,18 @@
                       'extension and has been disabled.\n') % ext)
             return
 
+    enabled = None
+    if 'HGWATCHMAN_ENABLE' in encoding.environ:
+        enabled = encoding.environ['HGWATCHMAN_ENABLE'].lower()
+
+    if enabled == 'true' or enabled == '':
+        pass
+    elif enabled == 'false':
+        return
+    else:
+        if not ui.interactive():
+            return
+
     if repo.local():
         # We don't work with subrepos either.
         #



To: lothiraldan, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D5588: watchman: disable fsmonitor when running non-interactively

pulkit (Pulkit Goyal)
indygreg requested changes to this revision.
indygreg added a comment.
This revision now requires changes to proceed.


  Why wouldn't we want automated, non-interactive tools to have the benefits of watchman? There are plenty of use cases where complex Mercurial operations are scripted and would benefit from watchman.
 
  Your commit message details an issue that I assume you encountered in the wild. Are there other ways we can work around this? Perhaps we can set the idle timeout/shutdown interval of watchman to be much smaller when Mercurial is non-interactive?

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5588

To: lothiraldan, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D5588: watchman: disable fsmonitor when running non-interactively

pulkit (Pulkit Goyal)
In reply to this post by pulkit (Pulkit Goyal)
lothiraldan added a comment.


  In https://phab.mercurial-scm.org/D5588#82922, @indygreg wrote:
 
  > Why wouldn't we want automated, non-interactive tools to have the benefits of watchman? There are plenty of use cases where complex Mercurial operations are scripted and would benefit from watchman.
  >
  > Your commit message details an issue that I assume you encountered in the wild. Are there other ways we can work around this? Perhaps we can set the idle timeout/shutdown interval of watchman to be much smaller when Mercurial is non-interactive?
 
 
  Yes what we saw in the wild is background jobs taking all the resources making interactive commands slower for users.
 
  I'm not sure what are the others workaround for this, I don't know if tuning the timeout / shutdown might be useful.
 
  There is also the possibility to put it behind a config knob.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5588

To: lothiraldan, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D5588: watchman: disable fsmonitor when running non-interactively

pulkit (Pulkit Goyal)
In reply to this post by pulkit (Pulkit Goyal)
lothiraldan updated this revision to Diff 13413.
Herald added a subscriber: mjpieters.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5588?vs=13224&id=13413

REVISION DETAIL
  https://phab.mercurial-scm.org/D5588

AFFECTED FILES
  hgext/fsmonitor/__init__.py

CHANGE DETAILS

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -161,6 +161,9 @@
 configitem('fsmonitor', 'blacklistusers',
     default=list,
 )
+configitem('fsmonitor', 'enable_on_non_interactive',
+    default=True,
+)
 configitem('hgwatchman', 'verbose',
     default=True,
 )
@@ -778,6 +781,24 @@
                       'extension and has been disabled.\n') % ext)
             return
 
+    enabled = None
+    if 'HGWATCHMAN_ENABLE' in encoding.environ:
+        enabled = encoding.environ['HGWATCHMAN_ENABLE'].lower()
+
+    if enabled == 'true' or enabled == '':
+        pass
+    elif enabled == 'false':
+        ui.debug('fsmonitor: disabled through HGWATCHMAN_ENABLE env variable')
+        return
+    else:
+        interactive = ui.interactive()
+        enable_on_non_interactive = ui.configbool(
+            'fsmonitor', 'enable_on_non_interactive'
+        )
+        if not interactive and not enable_on_non_interactive:
+            ui.debug('fsmonitor: disabled for non-interactive commands')
+            return
+
     if repo.local():
         # We don't work with subrepos either.
         #



To: lothiraldan, #hg-reviewers, indygreg
Cc: mjpieters, indygreg, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
Reply | Threaded
Open this post in threaded view
|

D5588: watchman: disable fsmonitor when running non-interactively

pulkit (Pulkit Goyal)
In reply to this post by pulkit (Pulkit Goyal)
lothiraldan updated this revision to Diff 14069.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5588?vs=13413&id=14069

REVISION DETAIL
  https://phab.mercurial-scm.org/D5588

AFFECTED FILES
  hgext/fsmonitor/__init__.py

CHANGE DETAILS

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -161,6 +161,9 @@
 configitem('fsmonitor', 'blacklistusers',
     default=list,
 )
+configitem('fsmonitor', 'enable_on_non_interactive',
+    default=True,
+)
 configitem('fsmonitor', 'verbose',
     default=True,
 )
@@ -760,6 +763,24 @@
                       'extension and has been disabled.\n') % ext)
             return
 
+    enabled = None
+    if 'HGWATCHMAN_ENABLE' in encoding.environ:
+        enabled = encoding.environ['HGWATCHMAN_ENABLE'].lower()
+
+    if enabled == 'true' or enabled == '':
+        pass
+    elif enabled == 'false':
+        ui.debug('fsmonitor: disabled through HGWATCHMAN_ENABLE env variable')
+        return
+    else:
+        interactive = ui.interactive()
+        enable_on_non_interactive = ui.configbool(
+            'fsmonitor', 'enable_on_non_interactive'
+        )
+        if not interactive and not enable_on_non_interactive:
+            ui.debug('fsmonitor: disabled for non-interactive commands')
+            return
+
     if repo.local():
         # We don't work with subrepos either.
         #



To: lothiraldan, #hg-reviewers, indygreg
Cc: mjpieters, indygreg, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
[hidden email]
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel