Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ccache in FWBuild server? #27

Open
Harvie opened this issue Nov 28, 2019 · 3 comments
Open

Use ccache in FWBuild server? #27

Harvie opened this issue Nov 28, 2019 · 3 comments

Comments

@Harvie
Copy link

Harvie commented Nov 28, 2019

Hello,
i frequently build mongoose firmware with small changes. Do you think it would be possible to integrate ccache to mongoose FWBuild? From my experience it provides HUGE compiler speedup in cases where you have C/C++ project with lots of files and change only few of them between builds. I've been using it for Linux kernel builds, Firefox, FreeCAD and stuff like that. It saved me unbeleivable amount of time during these builds...

It hashes gcc commandline and source files and uses it as key to cache builds. So everytime you run gcc with same source code and arguments, it retruns cached output files rather than building them again.

Obviously this would need some kind of persistent storage mounted into docker container to keep the cached files across the builds.

https://ccache.dev/
https://github.com/ccache/ccache

@rojer
Copy link
Contributor

rojer commented Nov 28, 2019

i frequently build mongoose firmware with small changes.

me too, so i always keep a close eye on the speed of incremental builds, at least local ones.
and right now incremental local builds are already pretty fast - these already take, like, 5 seconds.
since you mention fwbuild, i assume you use remote builds. if remote builds are slow, it means either they are not properly incremental, or something else is slowing things down.
what kind of build times do you get?

@Harvie
Copy link
Author

Harvie commented Nov 28, 2019

me too, so i always keep a close eye on the speed of incremental builds, at least local ones.

What is incremental build? How do i tell if i use it or not?

since you mention fwbuild, i assume you use remote builds.

I use mos build --local --verbose , that AFAIK launches FWBuild server in docker at localhost in order to build localy. This takes 1m40s to build my project. Even unchanged components of firmware get rebuilt everytime.

@rojer
Copy link
Contributor

rojer commented Nov 28, 2019

What is incremental build? How do i tell if i use it or not?

incremental means we only build sources that changed, or if header changed, sources depending on that header. this is how it's supposed to be.

first clean build - about 1.5 mins:

[rojer@nba ~/cesanta/mongoose-os-apps/demo-c master]$ time mos build --local --platform esp32 --clean
Fetching libmbedtls-esp32.a (latest) from https://github.com/mongoose-os-libs/mbedtls/releases/download/latest/libmbedtls-esp32.a...
Fetching libmongoose-esp32.a (latest) from https://github.com/mongoose-os-libs/mongoose/releases/download/latest/libmongoose-esp32.a...
Fetching libota-common-esp32.a (latest) from https://github.com/mongoose-os-libs/ota-common/releases/download/latest/libota-common-esp32.a...
Fetching libota-http-client-esp32.a (latest) from https://github.com/mongoose-os-libs/ota-http-client/releases/download/latest/libota-http-client-esp32.a...
Fetching libota-shadow-esp32.a (latest) from https://github.com/mongoose-os-libs/ota-shadow/releases/download/latest/libota-shadow-esp32.a...
Fetching libdash-esp32.a (latest) from https://github.com/mongoose-os-libs/dash/releases/download/latest/libdash-esp32.a...
Fetching libota-http-server-esp32.a (latest) from https://github.com/mongoose-os-libs/ota-http-server/releases/download/latest/libota-http-server-esp32.a...
Fetching librpc-service-ota-esp32.a (latest) from https://github.com/mongoose-os-libs/rpc-service-ota/releases/download/latest/librpc-service-ota-esp32.a...
Firmware saved to /home/rojer/cesanta/mongoose-os-apps/demo-c/build/fw.zip

real    1m41.586s
user    0m2.443s
sys     0m0.740s

incremental build with no changes - 7s:

[rojer@nba ~/cesanta/mongoose-os-apps/demo-c master]$ time mos build --local --platform esp32 
Firmware saved to /home/rojer/cesanta/mongoose-os-apps/demo-c/build/fw.zip

real    0m7.041s
user    0m1.688s
sys     0m0.454s

incremental build with 1 file changed:

[rojer@nba ~/cesanta/mongoose-os-apps/demo-c master]$ touch src/main.c 
[rojer@nba ~/cesanta/mongoose-os-apps/demo-c master]$ time mos build --local --platform esp32 
Firmware saved to /home/rojer/cesanta/mongoose-os-apps/demo-c/build/fw.zip

real    0m10.116s
user    0m1.737s
sys     0m0.402s

I use mos build --local --verbose , that AFAIK launches FWBuild server in docker at localhost in order to build localy.

no, it runs docker run ... make, basically.
fwbuild is the daemon that handles remote build requests (frmo mos without --remote).

This takes 1m40s to build my project. Even unchanged components of firmware get rebuilt everytime.

this is not right. does build directory get wiped between builds or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants