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

[script] leverage slc SDK cache and add ccache to speedup incremental builds #873

Merged
merged 4 commits into from
Jun 26, 2024

Conversation

lmnotran
Copy link
Contributor

@lmnotran lmnotran commented May 30, 2024

Summary of changes

  • slc
    • Remove the --clear-cache flag to leverage SDK cache
    • Switch to using daemon-mode. Reduces slc startup time
  • Add ccache to build scripts for potential build speedups. See more below
  • GitHub Actions
    • Only pull required LFS files
    • Cache ARM Toolchain between builds

CCache

When building with no compiler cache, the build proceeds as normal and takes a normal amount of time. For the Build/arm-gcc-* workflows, it usually takes ~20-30 min for the workflow to run completely.

Example: Build/arm-gcc-12.2.Rel1 (no compiler cache)

If you examine this run, you can see during the setup, there's no cache found (log here). Looking at the ccache statistics during teardown, you can see there was a very low cache hit rate.

ccache hits: 2.05 %
Time spent in Build step: 22m 22s

Example: Build/arm-gcc-12.2.Rel1 (with compiler cache)

During this second run, a compiler cache was located and added to the workspace. This speedup is also reflected in the ccache statistics.

ccache hits: 99.46 %
Time spent in Build step: 2m 52s

These performance gains are not limited to GitHub actions builds. CCache has been added to the script/build and script/build-example-apps scripts, meaning builds on development machines will also benefit from the same speedup potential.

One thing to note is that ccache will bring the most benefit when iterating on changes. Of course, the speedup will be reduced in scenarios where the cache cannot be leveraged, including but not limited to the first build when building for a board you haven't built before, switching branches, or making any wide-reaching changes.

@lmnotran lmnotran force-pushed the feature/slc-daemon-mode branch 2 times, most recently from 6c9d6b5 to ff16ca8 Compare May 30, 2024 21:11
@lmnotran lmnotran force-pushed the feature/slc-daemon-mode branch 5 times, most recently from f74f2f2 to 49834ac Compare June 24, 2024 13:13
@lmnotran lmnotran changed the title Feature/slc daemon mode [script] leverage slc SDK cache and add ccache to speedup incremental builds Jun 24, 2024
lmnotran added 2 commits June 26, 2024 10:19
This provides a small speed-up when working with SLC

Also, remove the `--clear-cache` option to leverage SLC's SDK component cache
@lmnotran lmnotran force-pushed the feature/slc-daemon-mode branch from 49834ac to 8d6b422 Compare June 26, 2024 14:20
@lmnotran lmnotran changed the title [script] leverage slc SDK cache and add ccache to speedup incremental builds [script] leverage slc SDK cache and add ccache to speedup incremental builds Jun 26, 2024
@lmnotran lmnotran marked this pull request as ready for review June 26, 2024 14:42
@suveshpratapa
Copy link
Member

@lmnotran There should be no user facing changes from this, I assume? One would continue to use slc as before and just notice improvements when iterating on a build? Are there any pitfalls to watch out for / build dirs to clear if we do want a fresh build?

@lmnotran
Copy link
Contributor Author

@suveshpratapa

@lmnotran There should be no user facing changes from this, I assume? One would continue to use slc as before and just notice improvements when iterating on a build?

Nope! There are no user-facing changes. Users will continue to build in the same way as they have been before. They don't even need to install/use ccache if they don't want to. It's only used when ccache is present in the user's PATH.

Are there any pitfalls to watch out for / build dirs to clear if we do want a fresh build?

Nope! ccache is aware of the changes that would determine if the compiler cache is able to be leveraged safely or not. If a user is looking to do a fresh/clean build, they can just delete the build/ folder and a fresh build will happen, leveraging the compiler cache when possible. See more on how ccache works: https://ccache.dev/manual/4.8.2.html#_how_ccache_works

Copy link
Member

@suveshpratapa suveshpratapa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lmnotran lmnotran force-pushed the feature/slc-daemon-mode branch from 8d6b422 to d444ac8 Compare June 26, 2024 15:49
Copy link
Contributor

@romacdon romacdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - do we want to squash commits?

@lmnotran
Copy link
Contributor Author

LGTM - do we want to squash commits?

Squash on merge is fine. I'd like to keep them separate in the branch though. They're all independent and separate changes/ideas

@lmnotran
Copy link
Contributor Author

@jwhui could you review this when you get a chance please? Thanks!

@lmnotran lmnotran requested a review from jwhui June 26, 2024 18:50
@jwhui jwhui merged commit 502dd20 into openthread:main Jun 26, 2024
8 checks passed
@lmnotran lmnotran deleted the feature/slc-daemon-mode branch June 27, 2024 04:13
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

Successfully merging this pull request may close these issues.

5 participants