Mercurial > hg
comparison tests/test-simple-update.t @ 38731:ef3838a47503
worker: ability to disable thread unsafe tasks
The worker on Windows is implemented using a thread pool. If worker
tasks are not thread safe, badness can occur. In addition, if tasks
are executing CPU bound code and holding onto the GIL, there will be
non-substantial overhead in Python context switching between active
threads. This can result in significant slowdowns of tasks.
This commit teaches the code for determining whether to use a worker
to take thread safety into account. Effectively, thread unsafe tasks
don't use the thread-based worker on Windows.
Differential Revision: https://phab.mercurial-scm.org/D3962
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Wed, 18 Jul 2018 09:46:45 -0700 |
parents | d0abd7949ea3 |
children | f1186c292d03 |
comparison
equal
deleted
inserted
replaced
38730:69ed2cff4277 | 38731:ef3838a47503 |
---|---|
63 | 63 |
64 #if no-windows | 64 #if no-windows |
65 | 65 |
66 $ cat <<EOF > forceworker.py | 66 $ cat <<EOF > forceworker.py |
67 > from mercurial import extensions, worker | 67 > from mercurial import extensions, worker |
68 > def nocost(orig, ui, costperop, nops): | 68 > def nocost(orig, ui, costperop, nops, threadsafe=True): |
69 > return worker._numworkers(ui) > 1 | 69 > return worker._numworkers(ui) > 1 |
70 > def uisetup(ui): | 70 > def uisetup(ui): |
71 > extensions.wrapfunction(worker, 'worthwhile', nocost) | 71 > extensions.wrapfunction(worker, 'worthwhile', nocost) |
72 > EOF | 72 > EOF |
73 | 73 |