5 ms·
For those running `make`, add this to you shell init to set the concurrency level via env var: > expert MAKEFLAGS=-j$(nproc)
by 2bluesc 6y ago
For those running `make`, add this to you shell init to set the concurrency level via env var:
> expert MAKEFLAGS=-j$(nproc)
- smabie 6y ago*export
- s_gourichon 6y agoGood idea. make -j without a number should do that, instead of spawning processes like there’s no tomorrow.
- moonchild 6y agoTo be fair, having some way to spawn processes like there's no tomorrow is a good way to make sure there are no concurrency issues in your makefile. I had a makefile with a race condition that triggered only sporadically. However, giving it more threads significantly increased its rate of occurrence.
- PikachuEXE 6y agoAny doc that suggest this behaviour?
- exciteabletom 6y agoFrom the man page: > If the -j option is given without an argument, make will not limit the number of jobs that can run simultaneously.
- stewartesmith 6y agoWhat this practically means is that a plain "make -j" will spawn all the processes that could run concurrently. So if you're building 1,000 files, it'll spawn 1,000 processes. This can either be fine, or completely terrible, depending on the number of CPUs you have an the amount of memory each process uses.
- moonchild 6y agomake -j$(($(nproc)+2))
- _flux 6y agoAs a software developer one might also choose to use the switch -O as to not mangle the output in a (too) nondeterministic order. Or prefer ninja overall.
- fillest 6y agoSome software doesn't support that - building that way can randomly fail with very confusing errors.
- account42 6y agoThen that software should add the proper dependencies to their makefile.