platformio / platformio-core

Your Gateway to Embedded Software Development Excellence :alien:
https://platformio.org
Apache License 2.0
7.95k stars 792 forks source link

FYI - Build speed optimization - ccache massively speeds up build time #5018

Open zackees opened 1 day ago

zackees commented 1 day ago

Hi there, I'm making an emscripten docker file for platformio for a web compile of FastLED.

I've been grinding on build speed for the last week. I want to report that one of the biggest wins was slapping on ccache in front of the compiler.

As many have mentioned before, PlatformIO has a tendency to rebuild everything whenever order of deps/defines changes, which makes sense. ccache is a great way to mitigate that effect.

Today I discovered auto clean and disabling it. This makes it even faster. However I'm not sure what the failure condition is going to be with disabling auto-clean.

This compiler project is kind of a special case. Users pretty much just compile against FastLED. So my use case is how much can I pre-warm the ccache in release/debug/quick modes, stash that as a docker image layer. Then when a file is sent it just compiles then link against fastled. Right now I'm still dealing with linking against a bunch of object files. I've tried to combine this into a giant lib but no luck so far.

zackees commented 1 day ago

By the way, a super fast cloud compiler for platformio would be amazing. There is so much caching that can be done between all these different projects. There is also the benefit that the user doesn't have to install a giant framework to get something to compile.

In my case, I have a tool called fastled-wasm that just zips up a sketch (which is tiny) and the backed compiles it all in 4 seconds then sends it back. My 4 second compile is on a super weak cloud server at $7 a month.

Platformio, if it did this, could just install the necessary tools to upload the hex/bin to the actual device, and not do the 1.6GB download for RP2350 or the ESP32S3 for the framework dependencies.

Anyway, probably outside the scope of what PlatformIO wants to do. So I just wanted to share the result of the benefits that I'm seeing.