Skip to content
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

Closed

Conversation

kienanstewart
Copy link
Contributor

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 uses multiprocessing.cpu_count(), but decided to use len(os.sched_getaffinity(0)) to avoid importing multiprocessing in to the vlttng.py script.

@eepp
Copy link
Owner

eepp commented Sep 25, 2023

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:

config BR2_JLEVEL
	int "Number of jobs to run simultaneously (0 for auto)"
	default "0"
	help
	  Number of jobs to run simultaneously. If 0, determine
	  automatically according to number of CPUs on the host system.

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.
Copy link
Owner

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.

@@ -79,6 +79,13 @@ def _parse_args():
return args


def _jobs_default():
Copy link
Owner

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.

@@ -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()))
Copy link
Owner

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants