All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checksum: fix unstable sort of checksums
@ 2024-05-14 10:12 yang.xu
  2024-05-14 10:29 ` [bitbake-devel] " Richard Purdie
  0 siblings, 1 reply; 3+ messages in thread
From: yang.xu @ 2024-05-14 10:12 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Yang Xu

From: Yang Xu <yang.xu@mediatek.com>

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 <yang.xu@mediatek.com>
---
 lib/bb/checksum.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/bb/checksum.py b/lib/bb/checksum.py
index 557793d3..5294ddf1 100644
--- a/lib/bb/checksum.py
+++ b/lib/bb/checksum.py
@@ -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
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-14 11:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-14 10:12 [PATCH] checksum: fix unstable sort of checksums yang.xu
2024-05-14 10:29 ` [bitbake-devel] " Richard Purdie
2024-05-14 11:20   ` Yang Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.