All of lore.kernel.org
 help / color / mirror / Atom feed
From: <yang.xu@mediatek.com>
To: <bitbake-devel@lists.openembedded.org>
Cc: Yang Xu <yang.xu@mediatek.com>
Subject: [PATCH] checksum: fix unstable sort of checksums
Date: Tue, 14 May 2024 10:12:56 +0000	[thread overview]
Message-ID: <20240514101257.31020-1-yang.xu@mediatek.com> (raw)

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



             reply	other threads:[~2024-05-14 10:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-14 10:12 yang.xu [this message]
2024-05-14 10:29 ` [bitbake-devel] [PATCH] checksum: fix unstable sort of checksums Richard Purdie
2024-05-14 11:20   ` Yang Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240514101257.31020-1-yang.xu@mediatek.com \
    --to=yang.xu@mediatek.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.