Skip to content

ci: build-yocto: cleanup sstate-cache after the build #820

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

quaresmajose
Copy link
Contributor

@quaresmajose quaresmajose commented Mar 31, 2025

We need to clean up the ci local sstate-cache that is not used, otherwise it will grow infinitely.
This will take up significant space that will not be used by anyone since invalid sstate-cache
artefacts will no longer be needed.

Fixes #715

@quaresmajose quaresmajose force-pushed the cleanup-sstate-cache branch 2 times, most recently from 97e0576 to 575eb01 Compare March 31, 2025 17:24
export SSTATE_DIR=${CACHE_DIR}/sstate-cache
export KAS_WORK_DIR=$PWD/../kas
SSTATE_CACHE_MANAGEMENT="${KAS_WORK_DIR}/poky/scripts/sstate-cache-management.py --cache-dir ${SSTATE_DIR} --remove-duplicated --remove-orphans --debug --yes"
kas shell ci/${{ matrix.machine }}.yml --command "$SSTATE_CACHE_MANAGEMENT"
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure how long this script will take. My past recollection makes me think this will be pretty slow. Have you considered doing this on a cron schedule instead so that it doesn't affect day-to-day stuff as much?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yocto docs about sstate-cache-management says

It has the ability to purge all but the newest cache files on each architecture, and also to remove files that it considers unreachable by exploring a set of build configurations. However, this command requires a full build environment to be available and doesn’t work well covering multiple releases.

Which is not very encouraging to be honest..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for this first run it takes about 15 minutes for each machine but note that we have a very big sstate folder since it has never been cleaned yet. I expect to get much less time after this first interaction

@quaresmajose quaresmajose force-pushed the cleanup-sstate-cache branch 3 times, most recently from 7120836 to fb17b7e Compare April 1, 2025 09:58
@quaresmajose quaresmajose changed the title [WIP] build-yocto: cleanup sstate-cache ci: build-yocto: cleanup sstate-cache after the build Apr 1, 2025
@quaresmajose quaresmajose force-pushed the cleanup-sstate-cache branch from 4af2fe8 to 2b1b5e2 Compare April 1, 2025 11:40
@ndechesne
Copy link
Contributor

We should run it on push event only, not PR. First it would run less often, and then we really care about sstate for metadata which is merged, not what's in a PR which is temporary.

Copy link

github-actions bot commented Apr 1, 2025

Test Results

 3 files  ±0   6 suites  ±0   1m 57s ⏱️ ±0s
23 tests ±0  23 ✅ ±0  0 💤 ±0  0 ❌ ±0 
57 runs  ±0  57 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 18ba973. ± Comparison against base commit da66ef2.

♻️ This comment has been updated with latest results.

Copy link

github-actions bot commented Apr 1, 2025

@quaresmajose quaresmajose force-pushed the cleanup-sstate-cache branch 4 times, most recently from f4d5567 to 18ba973 Compare April 1, 2025 16:29
@quaresmajose
Copy link
Contributor Author

quaresmajose commented Apr 1, 2025

We should run it on push event only, not PR. First it would run less often, and then we really care about sstate for metadata which is merged, not what's in a PR which is temporary.

Good point! I have changed it to just run on git push events.

Copy link

github-actions bot commented Apr 1, 2025

Copy link

github-actions bot commented Apr 1, 2025

@koenkooi
Copy link
Contributor

koenkooi commented Apr 2, 2025

When I looked at clean-sstate-cache a few years ago, it would remove everything unrelated to your existing build, so it would delete sstate for all other machines. Does it still do this or has it become smarter?

@quaresmajose
Copy link
Contributor Author

When I looked at clean-sstate-cache a few years ago, it would remove everything unrelated to your existing build, so it would delete sstate for all other machines. Does it still do this or has it become smarter?

I believe the script is smart enough to support builds with more than one machine but I'm sure it will be like that. I will need to test this locally on my machine to actually see what it deletes.

@lumag
Copy link
Collaborator

lumag commented Apr 2, 2025

We should run it on push event only, not PR. First it would run less often, and then we really care about sstate for metadata which is merged, not what's in a PR which is temporary.

I'd go for a scheduled cleanup, e.g. once a week or so.

@ndechesne
Copy link
Contributor

that would indeed work better. even once a month.. but that also means we need to duplicate the build config/machines in that cleanup job, since we need to inherit the same matrix config, right?

@lumag
Copy link
Collaborator

lumag commented Apr 2, 2025

Can't we define machines in a common config file which gets included by both workflows?

@quaresmajose quaresmajose marked this pull request as draft June 25, 2025 17:08
@quaresmajose quaresmajose force-pushed the cleanup-sstate-cache branch from 18ba973 to c16b640 Compare June 25, 2025 17:08
We need to clean up the ci local sstate-cache that is not used, otherwise it will grow infinitely.
This will take up significant space that will not be used by anyone since invalid sstate-cache
artefacts will no longer be needed.

Since jobs on all machines in the matrix run simultaneously, we need some kind of lock
to ensure that only one runs at a time. We use the flock tool for that propose.

Signed-off-by: Jose Quaresma <[email protected]>
Signed-off-by: Jose Quaresma <[email protected]>
@quaresmajose quaresmajose force-pushed the cleanup-sstate-cache branch from c16b640 to 22e6473 Compare June 25, 2025 17:35
@quaresmajose quaresmajose self-assigned this Jul 3, 2025
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.

ci: add job to cleanup the unused local sstate-cache artifacts
5 participants