Openembedded Bitbake Development
 help / color / mirror / Atom feed
From: ecordonnier@snap.com
To: bitbake-devel@lists.openembedded.org
Cc: Etienne Cordonnier <ecordonnier@snap.com>
Subject: [PATCH] fetch: Avoid truth-testing the original environment
Date: Wed, 23 Sep 2026 19:09:36 +0200	[thread overview]
Message-ID: <20260923170936.1362930-1-ecordonnier@snap.com> (raw)

From: Etienne Cordonnier <ecordonnier@snap.com>

get_fetcher_environment() and runfetchcmd() check BB_ORIGENV with a truth
test for every export variable that is not set in the datastore. Truth
testing a DataSmart calls __len__(), which builds the set of all its keys,
so this repeatedly enumerates the whole original environment. BB_ORIGENV
is always a datastore when set, so compare it against None instead.

This reduces get_fetcher_environment(), called once per sstate object
checked on an HTTP mirror, from 753us to 24us. Checking 2,114 objects on
the Yocto sstate mirror with BB_NUMBER_THREADS = "8" reduced the time to
task execution from 26.6s to 24.5s on average.

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com>
---
 lib/bb/fetch/__init__.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bb/fetch/__init__.py b/lib/bb/fetch/__init__.py
index 55ab710f3..fb6278439 100644
--- a/lib/bb/fetch/__init__.py
+++ b/lib/bb/fetch/__init__.py
@@ -928,7 +928,7 @@ def get_fetcher_environment(d):
     origenv = d.getVar("BB_ORIGENV")
     for name in bb.fetch.FETCH_EXPORT_VARS:
         value = d.getVar(name)
-        if not value and origenv:
+        if not value and origenv is not None:
             value = origenv.getVar(name)
         if value:
             newenv[name] = value
@@ -961,7 +961,7 @@ def runfetchcmd(cmd, d, quiet=False, cleanup=None, log=None, workdir=None, extra
     origenv = d.getVar("BB_ORIGENV", False)
     env = os.environ.copy()
     for var in exportvars:
-        val = d.getVar(var) or (origenv and origenv.getVar(var))
+        val = d.getVar(var) or (origenv is not None and origenv.getVar(var))
         if val:
             env[var] = val
 
-- 
2.43.0



                 reply	other threads:[~2026-09-23 17:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260923170936.1362930-1-ecordonnier@snap.com \
    --to=ecordonnier@snap.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox