D1460: workers: add config to enable/diable workers

wlis (Wojciech Lis) phabricator at mercurial-scm.org
Mon Nov 20 13:37:17 EST 2017


wlis created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This adds config to disable/enable workers with default being enabled.

TEST PLAN
  enabled profile without updaing .hg/hgrc (the default should be to use workers) and ran
  hg sprase --enable-profile <profile>.sparse
  Watched in the proces explorer that hg started 12 new threads for materializing files (this is my worker.numcpus) value
  
  Added
  
    [worker]
    enabled = False
  
  to the .hg/hgrc and re ran the command. This time hg didn't spawn any new threads for matreializing of files

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/help/config.txt
  mercurial/worker.py

CHANGE DETAILS

diff --git a/mercurial/worker.py b/mercurial/worker.py
--- a/mercurial/worker.py
+++ b/mercurial/worker.py
@@ -82,7 +82,8 @@
     args - arguments to split into chunks, to pass to individual
     workers
     '''
-    if worthwhile(ui, costperarg, len(args)):
+    enabled = ui.configbool('worker', 'enabled', True)
+    if enabled and worthwhile(ui, costperarg, len(args)):
         return _platformworker(ui, func, staticargs, args)
     return func(*staticargs + (args,))
 
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -2547,6 +2547,10 @@
 directory updates in parallel on Unix-like systems, which greatly
 helps performance.
 
+``enabled``
+    Whether to enable workers code to be used.
+    (default: true)
+
 ``numcpus``
     Number of CPUs to use for parallel operations. A zero or
     negative value is treated as ``use the default``.



To: wlis, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list