-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set jobs default based on number of available CPUs #21
Conversation
0793ce4
to
c83ecb1
Compare
I wasn't sure about that since I just copied the default of GNU make, that is one job by default. But I guess it makes sense at a higher level, and it remains configurable. Buildroot does the same:
|
README.adoc
Outdated
@@ -318,6 +318,9 @@ used to create the virtual environment. | |||
|
|||
`vlttng` passes its `--jobs` (`-j`) option as is to `make`. | |||
|
|||
The default number of jobs is dynamic, based on the length of | |||
`os.sched_getaffinity()` for the current process. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default value of the `--jobs` option is the number of CPUs on your
system.
vlttng/vlttng_cli.py
Outdated
@@ -79,6 +79,13 @@ def _parse_args(): | |||
return args | |||
|
|||
|
|||
def _jobs_default(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just set a default_jobs
variable once at the beginning of _parse_args()
instead of calling it twice.
vlttng/vlttng_cli.py
Outdated
@@ -43,7 +43,7 @@ def _parse_args(): | |||
help='ignore project PROJECT (may be repeated)') | |||
ap.add_argument('-j', '--jobs', nargs='?', const=None, metavar='JOBS', | |||
action='store', type=int, | |||
default=1, help='number of make jobs to run simultaneously') | |||
default=_jobs_default(), help='number of make jobs to run simultaneously. Dynamic default: {}'.format(_jobs_default())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number of make jobs to run simultaneously instead of {}
I noticed `vlttng_quick.py` uses `multiprocessing.cpu_count()`, but decided to use `len(os.sched_getaffinity(0))` to avoid importing `multiprocessing` in to the `vlttng.py` script. Signed-off-by: Kienan Stewart <kstewart@efficios.com>
c83ecb1
to
fd5919b
Compare
When invoking vlttng, I think it's more helpful to users to use the available system resources by building with a higher level of parallelism by default when more CPUs are available.
vlttng_quick.py
suggests a similar approach to users by prompting with a default based on the available cpu count.I noticed
vlttng_quick.py
usesmultiprocessing.cpu_count()
, but decided to uselen(os.sched_getaffinity(0))
to avoid importingmultiprocessing
in to thevlttng.py
script.