checksum: fix unstable sort of checksums
PATCH 1/1 checksum: fix unstable sort of checksums
From: Yang Xu <[email protected]>
Using only the checksum as sorting key can lead to unstable results when same content files exist in different subfolders, affecting the taskhash calculation due to its sensitivity to the order of files in checksums.
This commit changes the sorting key to use both checksum and file path, ensuring stable sorting and enhancing sstate cache hit rates.
--- lib/bb/checksum.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/checksum.py +1 -1
@@ -140,5 +140,5 @@ class FileChecksumCache(MultiProcessCache): if checksum: checksums.append((pth, checksum)) - checksums.sort(key=operator.itemgetter(1)) + checksums.sort(key=lambda x:(x[1], x[0])) return checksums
Signature · 1 line
2.25.1
Quoted 19 lines · Yang Xu via lists.openembedded.org
From: Yang Xu <[email protected]>
Using only the checksum as sorting key can lead to unstable results when same content files exist in different subfolders, affecting the taskhash calculation due to its sensitivity to the order of files in checksums.
This commit changes the sorting key to use both checksum and file path, ensuring stable sorting and enhancing sstate cache hit rates.
Signed-off-by Yang Xu <[email protected]>---
lib/bb/checksum.py | 2 +-1 file changed, 1 insertion(+), 1 deletion(-)lib/bb/checksum.py +0
-0@@ -140,5 +140,5 @@ class FileChecksumCache(MultiProcessCache):
Quoted 7 lines
if checksum:
checksums.append((pth, checksum))
- checksums.sort(key=operator.itemgetter(1)) +checksums.sort(key=lambda x:(x[1], x[0]))return checksums
Which version of the project are you testing this with?
The checksum data is sorted where it is used in siggen.py so sorting here shouldn't make much difference?
Cheers,
Richard
Dear Richard,
Sorry, I use a old version "kirkstone". Yes, I see the unstable sort problem is fixed in siggen.py in newer version. I think the existed solution is also OK.
Please ignore current patch.
Thank you