arduino / arduino-builder

A command line tool for compiling Arduino sketches
GNU General Public License v2.0
458 stars 114 forks source link

[DO NOT MERGE] Fix parallel compilation disregarding -jobs flag #331

Closed facchinm closed 5 years ago

facchinm commented 5 years ago

The issue was due to the peculiar way concurrency and parallelism are handled in go. We used to set GOMAXPROC to 1 to avoid parallelizing the WaitGroup execution. This would work, in theory, unless the goroutines sleep. In that case, another goroutine is allowed to start concurrently (only 1 goroutine running in parallel, so GOMAXPROC is happy). Since our goroutines sleep (wait) after calling gcc, another task is started, without any hard limit, till the WaitGroup is completely spawned. On systems with limited resources (as RaspberryPi) and cores with lots of files this can trigger an out of memory condition.

facchinm commented 5 years ago

@ArduinoBot build this please

ArduinoBot commented 5 years ago

:white_check_mark: Build completed.

:arrow_down: Build URL: http://downloads.arduino.cc/PR/arduino-builder/arduino-builder-331.zip

:information_source: To test this build:

  1. Replace arduino-builder binary (you can find it where you installed the IDE) with the provided one
cmaglie commented 5 years ago

merged and fixed in https://github.com/arduino/arduino-cli/pull/356