Controlling How Many CPU’s are Used When Compiling Software on the Raspberry Pi

If you compile software on a Raspberry Pi you can overwhelm it by using too many CPU’s depending on how the application is setup to compile as well as what other software is running and what you are using for a drive, whether micro SD card, USB 2 vs USB 3. And for some applications you might want to assign an extra CPU if it defaults to only one. But you can always stay safe and just use one CPU.

When compiling BTOP++, it is configured to use all the available processors, and it caused me to lose my Mosh SSH connection for a while (at least with Mosh it reconnects). But it is much more manageable applying fewer CPU’s. Moreover, controlling the number of CPU’s is as simple as using the -jx command line parameter with make, with x being the number of CPU’s to use (technically it’s the number of jobs but they work per CPU and effectively limits how many CPU’s are utilized until the final part of compiling).

Here I’m compiling BTOP++ with one CPU:

make -j1

With this Raspberry Pi 3B+ not currently overclocked I can also get away with using 2 CPU’s though it did make my Docker SearxNG privacy search engine running on the same Pi time out when contacting the external search engines, so still not optimal so best to stick with one CPU here:

make -j2

With my Pi-Star Raspberry Pi 2B compiling MMDVMHost it defaults to one CPU:

make

With the Raspberry Pi 2B I can get away with using three CPU’s without issue:

make -j3

The biggest problem and bottleneck seems to be the drive bandwidth combined with CPU speed, as my Raspberry Pi 4B seems to do the best and it has a USB 3 SSD as it’s primary drive. Though BOP++ compiling with all CPU’s still caused me to lose Mosh SSH for a brief period in the linking and final part of compiling.

One way to get a little bit better performance with a micro SD card is to overclock the eMMC bus. I haven’t had any issues with this and good quality micro SD cards, and it made a noticeable improvement in read and write speeds.

So in case you went to compile a software package that uses all CPU’s and you lost your SSH connection, or your UI interface became unresponsive, controlling the numbers of CPU’s used will help you keep your system responsive and usable. Consequently, these Raspberry Pi’s are extremely capable little computers, but they have limitations we need to account for on occasion. But now at least you can baby them a bit when compiling applications you want to use or try.