Skip to contentSkip to conversation

Hash equivalence server garbage collection and *_qa tasks

DISCUSSION Philip Lorenz 3 participants 4 messages Aug 5, 2025 – Aug 6, 2025

lore
Share & tools
lore
#0 lore raw

Hi all,

we have deployed the clean up strategy proposed on IRC (mark all unihashes with a corresponding central sstate entry as alive, then sweep) for a couple of months and are observing that the *_qa tasks (e.g. do_package_qa) contribute a significant amount of "stale" hash equivalence entries to our database.

Technically this is expected as the tasks always produce the same outhash (and are thus mapped to the same unihash every time they are rebuilt) however the database schema currently does not seem to carry enough metadata (e.g. a creation timestamp) to identify those unihash entries and to mark them for removal.

Are there any known strategies to address this?

If not I see some possibilities to deal with this but I'd like to collect some feedback before proposing an actual change:

* Add a created column to the unihashes_v3 table and parametrize marking to omit entries older than a certain timestamp.
* Add a access time column to unihashes_v3. I do realize that this code path is performance critical so this would involve some mechanism to only update the access time of an entry once per day (similar to what relatime does for file systems). The advantage of this would be more sophisticated clean up strategies which keep all entries that have actually been used in the past x days.

Philip

Signature · 7 lines
Philip Lorenz
BMW Car IT GmbH, Software-Plattform, -Integration Connected Company, Lise-Meitner-Straße 14, 89081 Ulm
-------------------------------------------------------------------------
BMW Car IT GmbH
Management: Michael Böttrich, Chris Brandt, Christian Salzmann
Domicile and Court of Registry: München HRB 134810
-------------------------------------------------------------------------
#1 lore raw
Quoted 5 lines · Philip Lorenz via lists.openembedded.org

we have deployed the clean up strategy proposed on IRC (mark all unihashes with a corresponding central sstate entry as alive, then sweep) for a couple of months and are observing that the *_qa tasks (e.g. do_package_qa) contribute a significant amount of "stale" hash equivalence entries to our database.

I wonder if you can simply remove all package_qa entries once their amount exceeds a certain threshold. Such tasks with empty output are generally cheap to re-run.

Also, if you are using multiple hosts with distinct uids/gids for the users running the build, then pre-walnascar there was a bug that prevented sstate reuse and multiplied unnecessary package_qa entries, so taking this fix may help:

Author: Alexander Kanavin <[email protected]>
Date:   Tue Feb 25 13:09:22 2025 +0100

classes/insane: do not leak host uid/gid into package_qa sstate signatures

This prevented package_qa sstate from being reusable unless host uid/gid values would match exactly (and they unfortunately do on the
yocto autobuilder
worker machines which all share a 'pokybuild' user).

I noticed this when testing CDN sstate reuse, which otherwise works well.

Alex

#2 lore raw

Hi Alex,

Quoted 10 lines · Alexander Kanavin
Quoted 5 lines · Philip Lorenz via lists.openembedded.org

we have deployed the clean up strategy proposed on IRC (mark all unihashes with a corresponding central sstate entry as alive, then sweep) for a couple of months and are observing that the *_qa tasks (e.g. do_package_qa) contribute a significant amount of "stale" hash equivalence entries to our database.

I wonder if you can simply remove all package_qa entries once their amount exceeds a certain threshold. Such tasks with empty output are generally cheap to re-run.

This would eliminate that particular task (and admittedly also the biggest "offender" in our database) but similar issues remain for other tasks (e.g. do_recipe_qa where an equivalence removal would invalidate do_fetch and I guess therefore trigger a partial rebuild). On a closer look we also have some package_write_ipk tasks for packagegroup which have accumulated several thousand hash equivalence entries over the past couple of months.

Quoted 8 lines

Also, if you are using multiple hosts with distinct uids/gids for the users running the build, then pre-walnascar there was a bug that prevented sstate reuse and multiplied unnecessary package_qa entries, so taking this fix may help:

Author: Alexander Kanavin <[email protected]>
Date:   Tue Feb 25 13:09:22 2025 +0100
Quoted 8 lines

classes/insane: do not leak host uid/gid into package_qa sstate signatures

This prevented package_qa sstate from being reusable unless host uid/gid values would match exactly (and they unfortunately do on the
yocto autobuilder
worker machines which all share a 'pokybuild' user).

I noticed this when testing CDN sstate reuse, which otherwise works well.

Luckily we're not hit by that one (all builds happen in containers with static UIDs). The prime offenders are recipes with "nostamp" tasks before packaging (which we are going to refactor) and recipes which inject DISTRO_VERSION in their output (and we add the build input hash into DISTRO_VERSION so pretty much each build input change causes repackaging of said recipes).

Philip

Signature · 7 lines
Philip Lorenz
BMW Car IT GmbH, Software-Plattform, -Integration Connected Company, Lise-Meitner-Straße 14, 89081 Ulm
-------------------------------------------------------------------------
BMW Car IT GmbH
Management: Michael Böttrich, Chris Brandt, Christian Salzmann
Domicile and Court of Registry: München HRB 134810
-------------------------------------------------------------------------
#3 lore raw
In reply to Philip Lorenz
Quoted 8 lines · Philip Lorenz via lists.openembedded.org

Hi all,

we have deployed the clean up strategy proposed on IRC (mark all unihashes with a corresponding central sstate entry as alive, then sweep) for a couple of months and are observing that the *_qa tasks (e.g. do_package_qa) contribute a significant amount of "stale" hash equivalence entries to our database.

Quoted 5 lines

Technically this is expected as the tasks always produce the same outhash (and are thus mapped to the same unihash every time they are rebuilt) however the database schema currently does not seem to carry enough metadata (e.g. a creation timestamp) to identify those unihash entries and to mark them for removal.

I had to think about this for a couple of minutes to understand why the cleanup strategy isn't helping.

The issue is that the output for some tasks is always the same (empty) so *many* input hashes map to that one output hash. The cleanup strategy looks for active output hashes and assumes all the inputs are still useful. This means for cases where the output remains the same over long periods, hashes can accumulate fairly unbounded.

Quoted 1 line

Are there any known strategies to address this?

No, this is new territory.

Quoted 5 lines

If not I see some possibilities to deal with this but I'd like to collect some feedback before proposing an actual change:

* Add a created column to the unihashes_v3 table and parametrize marking to omit entries older than a certain timestamp.

I suspect that could end up fairly error prone as it depends on how the entries are accessed. If something is built infrequently, the data will be evicted even if for example the sstate is still there.

Quoted 6 lines

* Add a access time column to unihashes_v3. I do realize that this code path is performance critical so this would involve some mechanism to only update the access time of an entry once per day (similar to what relatime does for file systems). The advantage of this would be more sophisticated clean up strategies which keep all entries that have actually been used in the past x days.

This is an extremely performance sensitive code path as you say so I'm a bit nervous about putting in writes here, even infrequently. I'm not sure what to think on this one. I've copied Joshua.

Cheers,

Richard