<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>10945</bug_id>
          
          <creation_ts>2017-01-20 10:39:56 +0000</creation_ts>
          <short_desc>data_smart.py: _remove causes extra work</short_desc>
          <delta_ts>2018-10-18 12:42:17 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>4.99</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Patrick Ohly">patrick.ohly</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>69954</commentid>
    <comment_count>0</comment_count>
    <who name="Patrick Ohly">patrick.ohly</who>
    <bug_when>2017-01-20 10:39:56 +0000</bug_when>
    <thetext>getVarFlag() does some work related to _remove and the entire _remove multiple times. This is not wrong, but might have a performance impact.

There are two reasons for this:
- applying the split/join when there is nothing to remove
- removing when parsing=True

This can be reproduced with &quot;bitbake -e qemu-native&quot; and an entry in local.conf:
SRC_URI_remove_pn-foobar = &quot;removeme&quot;

It happens to break qemu-native because of an invalid _prepend without trailing space - that&apos;s how I noticed.

Here&apos;s a patch which might fix the issues. According to Richard, this needs good testing (bitbake selftest, parsing OE) because he has a feeling that getVarFlags() behaves this way for a reason.


diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
index 79d591a23..16840069b 100644
--- a/lib/bb/data_smart.py
+++ b/lib/bb/data_smart.py
@@ -772,7 +772,7 @@ class DataSmart(MutableMapping):
                 cachename = var + &quot;[&quot; + flag + &quot;]&quot;
             value = self.expand(value, cachename)
 
-        if value and flag == &quot;_content&quot; and local_var is not None and &quot;_remove&quot; in local_var:
+        if not parsing and value and flag == &quot;_content&quot; and local_var is not None and &quot;_remove&quot; in local_var:
             removes = []
             self.need_overrides()
             for (r, o) in local_var[&quot;_remove&quot;]:
@@ -784,9 +784,10 @@ class DataSmart(MutableMapping):
                 if match:
                     removes.extend(self.expand(r).split())
 
-            filtered = filter(lambda v: v not in removes,
-                              value.split())
-            value = &quot; &quot;.join(filtered)
+            if removes:
+                filtered = filter(lambda v: v not in removes,
+                                  value.split())
+                value = &quot; &quot;.join(filtered)
             if expand and var in self.expand_cache:
                  # We need to ensure the expand cache has the correct value
                  # flag == &quot;_content&quot; here</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>70007</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2017-01-23 14:48:21 +0000</bug_when>
    <thetext>I did take part of the fix:

http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=45df694a9f472ac2f684aadac4d864c3dfdc48a7

since that part was obviously correct. The other piece (parsing=True) needs further investigation.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>81897</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2018-10-18 12:42:17 +0000</bug_when>
    <thetext>Remaining optimisation added in http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=58e3f45d4b7d69d663ce7c94933d4da7b5f071e3</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>