Lower the number of cc1plus compilation threads

Hi all

I often crash my raspberry pi when compiling esphome sensors and stuff, and noticied that it might be caused by the number of compilation threads which is 4 by default.

Is there any configuration item in the esphome addon to set the number of threads to a lower value ?

Many thanks

Doesn’t help at all, can you point me to the the right change I need to make please?

This is uncalled for. @nickrout has provided you the first step towards a likely answer. The PlatformIO options allow you to control the compilation. Look at the link inside that section.

this is pretty useless, there are no option to decrease concurrency …

Really? Don’t think you are right, but what have you tried?

From memory, I checked and found that the number of threads is forced/equal to number of CPU Cores, that could be improved with some prarameter to specify the number of compliation threads (-j parameter)

I just don’t understand where to adjust it… I cannot find the platformio.ini file.

Looks like the problem was in not enough ram, so I increased my swap file and now it’s fine.
Thanks !

To clarify this:

There appears to be a command-line parameter to pio -j that you can use, however that’s not exposed via the platformio.ini and thus not available through platformio_options.

If you want to reduce the number of CPUs used (ie to do other things) but not reduce the number of jobs you can use taskset -c 0-3 esphome compile your.yaml (for example to only use the first 4 CPUs). HOWEVER this is counter-productive if you are trying to reduce RAM usage - you’ll at best have no impact.

As discussed increasing swap file is a way to not get outright crashes, at the cost of enormous slowdowns, but it doesn’t do what is needed reduce the load to a level that will make efficient use of the hardware in use.