# HG changeset patch # User Wojciech Lis # Date 1513538785 28800 # Node ID 471918fa7f460938bdd9d1aa498e342e7604f25f # Parent 71427ff1dff8c8af665a4c4a1605d7ffffec9a77 workers: add config to enable/diable workers 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 .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 Differential Revision: https://phab.mercurial-scm.org/D1460 diff -r 71427ff1dff8 -r 471918fa7f46 mercurial/configitems.py --- a/mercurial/configitems.py Mon Nov 20 10:27:41 2017 -0800 +++ b/mercurial/configitems.py Sun Dec 17 11:26:25 2017 -0800 @@ -1253,6 +1253,9 @@ coreconfigitem('worker', 'backgroundclosethreadcount', default=4, ) +coreconfigitem('worker', 'enabled', + default=True, +) coreconfigitem('worker', 'numcpus', default=None, ) diff -r 71427ff1dff8 -r 471918fa7f46 mercurial/help/config.txt --- a/mercurial/help/config.txt Mon Nov 20 10:27:41 2017 -0800 +++ b/mercurial/help/config.txt Sun Dec 17 11:26:25 2017 -0800 @@ -2563,6 +2563,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``. diff -r 71427ff1dff8 -r 471918fa7f46 mercurial/worker.py --- a/mercurial/worker.py Mon Nov 20 10:27:41 2017 -0800 +++ b/mercurial/worker.py Sun Dec 17 11:26:25 2017 -0800 @@ -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') + if enabled and worthwhile(ui, costperarg, len(args)): return _platformworker(ui, func, staticargs, args) return func(*staticargs + (args,))