Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mercurial-devel
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mercurial
mercurial-devel
Commits
dcb27c15
Commit
dcb27c15
authored
12 years ago
by
Bryan O'Sullivan
Browse files
Options
Downloads
Patches
Plain Diff
worker: estimate whether it's worth running a task in parallel
Not implemented for Windows yet.
parent
fed06dd0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mercurial/help/config.txt
+12
-0
12 additions, 0 deletions
mercurial/help/config.txt
mercurial/worker.py
+26
-1
26 additions, 1 deletion
mercurial/worker.py
with
38 additions
and
1 deletion
mercurial/help/config.txt
+
12
−
0
View file @
dcb27c15
...
...
@@ -1463,3 +1463,15 @@
``templates``
Where to find the HTML templates. Default is install path.
``worker``
----------
Parallel master/worker configuration. We currently perform working
directory updates in parallel on Unix-like systems, which greatly
helps performance.
``numcpus``
Number of CPUs to use for parallel operations. Default is 4 or the
number of CPUs on the system, whichever is larger. A zero or
negative value is treated as ``use the default``.
This diff is collapsed.
Click to expand it.
mercurial/worker.py
+
26
−
1
View file @
dcb27c15
...
...
@@ -5,7 +5,8 @@
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
import
os
from
i18n
import
_
import
os
,
util
def
countcpus
():
'''
try to count the number of CPUs on the system
'''
...
...
@@ -27,3 +28,27 @@
pass
return
1
def
_numworkers
(
ui
):
s
=
ui
.
config
(
'
worker
'
,
'
numcpus
'
)
if
s
:
try
:
n
=
int
(
s
)
if
n
>=
1
:
return
n
except
ValueError
:
raise
util
.
Abort
(
_
(
'
number of cpus must be an integer
'
))
return
min
(
max
(
countcpus
(),
4
),
32
)
if
os
.
name
==
'
posix
'
:
_startupcost
=
0.01
else
:
_startupcost
=
1e30
def
worthwhile
(
ui
,
costperop
,
nops
):
'''
try to determine whether the benefit of multiple processes can
outweigh the cost of starting them
'''
linear
=
costperop
*
nops
workers
=
_numworkers
(
ui
)
benefit
=
linear
-
(
_startupcost
*
workers
+
linear
/
workers
)
return
benefit
>=
0.15
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment