Build priority

Why builds run at low priority, what that covers, and how to change it

Build priority

Builds here run at low priority on purpose, so that compiling does not make the machine unusable while you work.

This page says what that covers, what it does not, and how to change it.

What happens by default

Every process the build starts — the compiler, the linker, the shader baker, the help generator and the rest — is launched through a low-priority wrapper. On Linux and macOS that is nice -n 19. On Windows it is lowprio, a small tool this project builds, because Windows ships no equivalent binary.

Priority is inherited, so wrapping the outermost process covers everything it starts in turn.

Expect a contended build to take longer. That is the trade: the build yields the processor whenever anything else wants it. On an otherwise idle machine you should see no difference at all.

What it does not cover

Only the processor. Neither mechanism lowers disk priority, so a heavy link can still make the disk busy enough to notice.

On Linux the obvious companion, ionice -c 3, does nothing on most modern hardware: I/O scheduling classes are implemented by the I/O scheduler, and NVMe devices commonly select none, which implements none of them. Check yours:

cat /sys/block/nvme0n1/queue/scheduler

If that prints [none], ionice is inert on that device and you need one of the routes below instead.

On Windows the same limit applies for the same reason, and Microsoft says so directly: adjusting CPU priority "is not sufficient… even an idle CPU priority process can easily interfere with system responsiveness when it uses the disk and memory".

Turning it off for a batch build

If nobody is at the keyboard and you just want the build finished, edit the one line that names the mechanism:

integration/qbs/imports/lowpriority.js
    var POSIX_PREFIX = ["nice", "-n", "19"];

Set it to [] to disable the wrapper entirely. It is one line on purpose — every tool in the build derives its prefix from it.

Making it stronger

Three options, in increasing order of both effectiveness and effort.

A lower niceness is not available — 19 is already the maximum.

chrt --idle runs the build only when nothing else wants the processor. Replace the line above with:

var POSIX_PREFIX = ["chrt", "--idle", "0"];

Be aware this is genuinely idle: a build started before a long working session may make almost no progress until you stop.

A cgroup is the only route here that reaches disk as well as processor. It wraps the whole build rather than each tool, so it applies to the command you type, not to the tree:

systemd-run --user --scope -p CPUWeight=20 -p IOWeight=20 qbs build

IOWeight needs an I/O scheduler that implements weights — bfq, not none. Switching a device to it, until reboot:

echo bfq | sudo tee /sys/block/nvme0n1/queue/scheduler
In this section
Topics
reference build priority nice performance
See also