Left the Build Running
In March I made a few attempts to compile the 2.2 branch of Swift on my Raspberry Pi 2s. The attempts weren’t successful, and unfortunately I didn’t have time to troubleshoot further. These build attempts did have an interesting failure case, though. Rather than failing with an error they would simply get stuck attempting to generate libswiftStdlibStubs.a
, pegging a single CPU core at 100%:
...
[510/560] Building CXX object stdlib/public/stubs/CMakeFiles/swiftStdlibStubs-linux-armv7-static.dir/UnicodeNormalization.cpp.o
[511/560] Generating ../../.././lib/swift/linux/libswiftStdlibStubs.a
[512/560] Linking CXX static library lib/swift_static/linux/armv7/libswiftStdlibStubs.a
[513/560] Generating ../../.././lib/swift_static/linux/libswiftStdlibStubs.a
So what happens if you forget that you started a build like this and leave it running for ten days? Well….I forgot, and found out:
Never ending build
Yes, that single process has used 247 hours of CPU time.
And what about the CPU temperature? As part of my current build script I log the CPU temperature from /sys/class/thermal/thermal_zone0/temp
every five minutes for the duration of the build:
On the left side of the graph we can see higher CPU temperatures peaking around 67°C when all four cores were in use. While the CPU stayed at its maximum clock rate (900MHz) until I stopped the build, with only a single core in use it spent most of the ten days between 44°C and 50°C.1
Fortunately This Happened on a Pi
Occasionally I spin up high-powered VMs on a certain cloud service to see how long it takes to compile Swift on something more powerful than a Raspberry Pi 2. Since I only keep these VMs online for less than an hour this is quite affordable, but I always worry that I’ll forget to remove one of them and end up a month later with a bill for hundreds or even thousands of dollars of usage.
For me, this is one of the reasons I love the Raspberry Pis: The only recurring cost of keeping them running is their power consumption, and even with Japan’s moderately-high electricity prices a fully-loaded Raspberry Pi 2 could cost less than $5/year to run.2
Even if you leave the build running, they aren’t going to break the bank.
- These fluctuations in temperature are most likely due to changes in the ambient temperature of my room. [return]
- The current draw for a Raspberry Pi 2 under load has been measured at around 420 mA, or 2.1 watts. Assuming electricity costs around 22 yen per 1kWh, this would come to about 405 JPY/year or about 3.74 USD as a write this post. At this point the efficiency of your USB adapter becomes an issue. [return]