Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Use # of processors + 1 available to OS scheduler on Linux when building #100

Merged
merged 2 commits into from
Feb 6, 2015

Conversation

xyziemba
Copy link

@xyziemba xyziemba commented Feb 6, 2015

getconf _NPROCESSORS_ONLN provides the number of cores available to
the OS scheduler, while nproc provides the number of cores available
to nproc itself. We want to use the former value since make spawns
new processes instead of running compilation tasks in the same process.
(FWIW, the two values are usually the same, but getconf gets us the
value that we actually want.)

Additionally, getconf is available on Mac OSX while nproc is not.

I also fixed the printout of the make command that's actually
executed when we build.

Also, thank you to Sedat Dilek for reporting this via email.

`getconf _NPROCESSORS_ONLN` provides the number of cores available to
the OS scheduler, while `nproc` provides the number of cores available
to `nproc` itself. We want to use the former value since make spawns
new processes instead of running compilation tasks in the same process.
(FWIW, the two values are usually the same, but `getconf` gets us the
value that we actually want.)

Additionally, `getconf` is available on Mac OSX while `nproc` is not.

I also fixed the printout of the `make` command that's actually
executed when we build.
@xyziemba
Copy link
Author

xyziemba commented Feb 6, 2015

It turns out that N + 1 processors is slightly faster, 2-3%, than N processors. I'm going to update this to use N+1 processors.

N+1 processors appears to perform 2-3% faster than using
just N processors. I've done an A/B test both locally and on
a cloud VM.

Fixes for this and the previous commit were reported by Sedar
Dilek <sedar.dilek@gmail.com>. Thanks!
@xyziemba xyziemba changed the title Use # of processors availabe to OS scheduler on Linux when building Use # of processors + 1 available to OS scheduler on Linux when building Feb 6, 2015
@sergiy-k
Copy link

sergiy-k commented Feb 6, 2015

LGTM

@sergiy-k sergiy-k mentioned this pull request Feb 6, 2015
@jkotas
Copy link
Member

jkotas commented Feb 6, 2015

LGTM

jkotas added a commit that referenced this pull request Feb 6, 2015
Use # of processors + 1 available to OS scheduler on Linux when building
@jkotas jkotas merged commit a85beeb into dotnet:master Feb 6, 2015
@cnblogs-dudu
Copy link

Ingenious solution!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants