
Dear Mike,
In message 200812090056.25498.vapier@gentoo.org you wrote:
-: ${JOBS:=} +# Determine number of CPU cores if no default was set +: ${BUILD_NCPUS:"`getconf _NPROCESSORS_ONLN`"}
+if [ "$BUILD_NCPUS" -gt 1 ]
no point in quoting here ... if it isnt numeric, then -gt will fail, and all numeric values lack whitespace ...
You are wrong. This is defensive programming against invalid user input.
Assume the user runs
BUILD_NCPUS=' ' MAKEALL
...
Without the quoting, we get a "[: -gt: unary operator expected" error message; with the quotes we single process build as (probably) expected.
+then
- JOBS-j`expr "$BUILD_NCPUS" + 1`
+else
- JOBS""
+fi
i generally see the heuristic (cpus * 2) rather than (cpus + 1) ... benchmarks tend to favor that as well ...
This obviously depends onyour benchmarks. For U-Boot builds, all systems I've checked (with 512 MB or more of RAM) tend to have all required files in RAM, so the only I/O is writing the object files and binaries out - which is negligable. In other words, the system is nearly 100% CPU bound. In this case, (cpus + 1) seems more appropriate to me. But YMMV ...
Best regards,
Wolfgang Denk