Skip to contentSkip to conversation

lib/bb: Add BB_SIGNATURE_LOCAL_DIRS_EXCLUDE to speed-up taskhash on directories

PATCH Superseded Aníbal Limón 4 participants 7 messages Nov 13, 2019 – Nov 25, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/bb: Add BB_SIGNATURE_LOCAL_DIRS_EXCLUDE to speed-up taskhash on directories

The new BB_SIGNATURE_LOCAL_DIRS_EXCLUDE allows you to specify a list of directories to exclude when making taskhash, our specific case is using SRC_URI that points local VCS directory.

In OE-Core this variable could be set by default to:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = ".cvs .git .svn"

---
 lib/bb/checksum.py        | 5 +++--
 lib/bb/fetch2/__init__.py | 4 ++--
 lib/bb/siggen.py          | 5 +++--
 3 files changed, 8 insertions(+), 6 deletions(-)
lib/bb/checksum.py +3 -2
index 5bc8a8fc..677020f4 100644
@@ -74,7 +74,7 @@ class FileChecksumCache(MultiProcessCache):
             else:
                 dest[0][h] = source[0][h]
 
-    def get_checksums(self, filelist, pn):
+    def get_checksums(self, filelist, pn, localdirsexclude):
         """Get checksums for a list of files"""
 
         def checksum_file(f):
@@ -90,7 +90,8 @@ class FileChecksumCache(MultiProcessCache):
             if pth == "/":
                 bb.fatal("Refusing to checksum /")
             dirchecksums = []
-            for root, dirs, files in os.walk(pth):
+            for root, dirs, files in os.walk(pth, topdown=True):
+                [dirs.remove(d) for d in list(dirs) if d in localdirsexclude]
                 for name in files:
                     fullpth = os.path.join(root, name)
                     checksum = checksum_file(fullpth)
lib/bb/fetch2/__init__.py +2 -2
index 07de6c26..731c1608 100644
@@ -1197,14 +1197,14 @@ def get_checksum_file_list(d):
 
     return " ".join(filelist)
 
-def get_file_checksums(filelist, pn):
+def get_file_checksums(filelist, pn, localdirsexclude):
     """Get a list of the checksums for a list of local files
 
     Returns the checksums for a list of local files, caching the results as
     it proceeds
 
     """
-    return _checksum_cache.get_checksums(filelist, pn)
+    return _checksum_cache.get_checksums(filelist, pn, localdirsexclude)
 
 
 class FetchData(object):
lib/bb/siggen.py +3 -2
index a4bb1ff7..f110fd72 100644
@@ -123,6 +123,7 @@ class SignatureGeneratorBasic(SignatureGenerator):
 
         self.unihash_cache = bb.cache.SimpleCache("1")
         self.unitaskhashes = self.unihash_cache.init_cache(data, "bb_unihashes.dat", {})
+        self.localdirsexclude = (data.getVar("BB_SIGNATURE_LOCAL_DIRS_EXCLUDE") or "").split()
 
     def init_rundepcheck(self, data):
         self.taskwhitelist = data.getVar("BB_HASHTASK_WHITELIST") or None
@@ -221,9 +222,9 @@ class SignatureGeneratorBasic(SignatureGenerator):
 
         if task in dataCache.file_checksums[fn]:
             if self.checksum_cache:
-                checksums = self.checksum_cache.get_checksums(dataCache.file_checksums[fn][task], recipename)
+                checksums = self.checksum_cache.get_checksums(dataCache.file_checksums[fn][task], recipename, self.localdirsexclude)
             else:
-                checksums = bb.fetch2.get_file_checksums(dataCache.file_checksums[fn][task], recipename)
+                checksums = bb.fetch2.get_file_checksums(dataCache.file_checksums[fn][task], recipename, self.localdirsexclude)
             for (f,cs) in checksums:
                 self.file_checksum_values[tid].append((f,cs))
                 if cs:
Signature · 1 line
2.24.0
#1 lore raw
Quoted 7 lines · Aníbal Limón

The new BB_SIGNATURE_LOCAL_DIRS_EXCLUDE allows you to specify a list of directories to exclude when making taskhash, our specific case is using SRC_URI that points local VCS directory.

In OE-Core this variable could be set by default to:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = ".cvs .git .svn"

I'm wondering if we should be adventurous and make this the default value? :)

Cheers,

Richard

#2 lore raw
In reply to Aníbal Limón
Quoted 9 lines · Aníbal Limón

The new BB_SIGNATURE_LOCAL_DIRS_EXCLUDE allows you to specify a list of directories to exclude when making taskhash, our specific case is using SRC_URI that points local VCS directory.

In OE-Core this variable could be set by default to:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = ".cvs .git .svn"

I like the approach. perhaps a sane default would be nice.

Quoted 83 lines
---
 lib/bb/checksum.py        | 5 +++--
 lib/bb/fetch2/__init__.py | 4 ++--
 lib/bb/siggen.py          | 5 +++--
 3 files changed, 8 insertions(+), 6 deletions(-)
lib/bb/checksum.py +3 -2
index 5bc8a8fc..677020f4 100644
@@ -74,7 +74,7 @@ class FileChecksumCache(MultiProcessCache):
             else:
                 dest[0][h] = source[0][h]
 
-    def get_checksums(self, filelist, pn):
+    def get_checksums(self, filelist, pn, localdirsexclude):
         """Get checksums for a list of files"""
 
         def checksum_file(f):
@@ -90,7 +90,8 @@ class FileChecksumCache(MultiProcessCache):
             if pth == "/":
                 bb.fatal("Refusing to checksum /")
             dirchecksums = []
-            for root, dirs, files in os.walk(pth):
+            for root, dirs, files in os.walk(pth, topdown=True):
+                [dirs.remove(d) for d in list(dirs) if d in localdirsexclude]
                 for name in files:
                     fullpth = os.path.join(root, name)
                     checksum = checksum_file(fullpth)
lib/bb/fetch2/__init__.py +2 -2
index 07de6c26..731c1608 100644
@@ -1197,14 +1197,14 @@ def get_checksum_file_list(d):
 
     return " ".join(filelist)
 
-def get_file_checksums(filelist, pn):
+def get_file_checksums(filelist, pn, localdirsexclude):
     """Get a list of the checksums for a list of local files
 
     Returns the checksums for a list of local files, caching the results as
     it proceeds
 
     """
-    return _checksum_cache.get_checksums(filelist, pn)
+    return _checksum_cache.get_checksums(filelist, pn, localdirsexclude)
 
 
 class FetchData(object):
lib/bb/siggen.py +3 -3
index a4bb1ff7..f110fd72 100644
@@ -123,6 +123,7 @@ class SignatureGeneratorBasic(SignatureGenerator):
 
         self.unihash_cache = bb.cache.SimpleCache("1")
         self.unitaskhashes = self.unihash_cache.init_cache(data, "bb_unihashes.dat", {})
+        self.localdirsexclude = (data.getVar("BB_SIGNATURE_LOCAL_DIRS_EXCLUDE") or "").split()
 
     def init_rundepcheck(self, data):
         self.taskwhitelist = data.getVar("BB_HASHTASK_WHITELIST") or None
@@ -221,9 +222,9 @@ class SignatureGeneratorBasic(SignatureGenerator):
 
         if task in dataCache.file_checksums[fn]:
             if self.checksum_cache:
-                checksums = self.checksum_cache.get_checksums(dataCache.file_checksums[fn][task], recipename)
+                checksums = self.checksum_cache.get_checksums(dataCache.file_checksums[fn][task], recipename, self.localdirsexclude)
             else:
-                checksums = bb.fetch2.get_file_checksums(dataCache.file_checksums[fn][task], recipename)
+                checksums = bb.fetch2.get_file_checksums(dataCache.file_checksums[fn][task], recipename, self.localdirsexclude)
             for (f,cs) in checksums:
                 self.file_checksum_values[tid].append((f,cs))
                 if cs:
--

2.24.0

--
_______________________________________________
bitbake-devel mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/bitbake-devel

#3 lore raw
Quoted 9 lines

-----Original Message-----
From: [email protected] <bitbake-devel- [email protected]> On Behalf Of Khem Raj
Sent: den 14 november 2019 03:55
To: Aníbal Limón <[email protected]>
Cc: bitbake-devel <[email protected]>
Subject: Re: [bitbake-devel] [PATCH] lib/bb: Add BB_SIGNATURE_LOCAL_DIRS_EXCLUDE to speed-up taskhash on directories

Quoted 10 lines
Quoted 8 lines · Aníbal Limón

The new BB_SIGNATURE_LOCAL_DIRS_EXCLUDE allows you to specify a list of directories to exclude when making taskhash, our specific case is using SRC_URI that points local VCS directory.

In OE-Core this variable could be set by default to:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = ".cvs .git .svn"

That should be:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = "CVS .git .svn"

Quoted 1 line

I like the approach. perhaps a sane default would be nice.

//Peter

#4 lore raw
Quoted 16 lines · Peter Kjellerstedt
Quoted 16 lines

-----Original Message-----
From: [email protected] <bitbake-devel- [email protected]> On Behalf Of Khem Raj
Sent: den 14 november 2019 03:55
To: Aníbal Limón <[email protected]>
Cc: bitbake-devel <[email protected]>
Subject: Re: [bitbake-devel] [PATCH] lib/bb: Add BB_SIGNATURE_LOCAL_DIRS_EXCLUDE to speed-up taskhash on directories

Quoted 5 lines · Aníbal Limón

The new BB_SIGNATURE_LOCAL_DIRS_EXCLUDE allows you to specify a list of directories to exclude when making taskhash, our specific case is using SRC_URI that points local VCS directory.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

In OE-Core this variable could be set by default to:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = ".cvs .git .svn"

That should be:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = "CVS .git .svn"

So I will change to,

+ self.localdirsexclude = (data.getVar("BB_SIGNATURE_LOCAL_DIRS_EXCLUDE") or "CVS .git .svn").split()

Any other directory to add it?

Cheers,
Anibal

Quoted 6 lines
Quoted 2 lines

I like the approach. perhaps a sane default would be nice.

//Peter

#5 lore raw
Quoted 29 lines · Anibal Limon
Quoted 16 lines · Peter Kjellerstedt
Quoted 16 lines

-----Original Message-----
From: [email protected] <bitbake-devel- [email protected]> On Behalf Of Khem Raj
Sent: den 14 november 2019 03:55
To: Aníbal Limón <[email protected]>
Cc: bitbake-devel <[email protected]>
Subject: Re: [bitbake-devel] [PATCH] lib/bb: Add BB_SIGNATURE_LOCAL_DIRS_EXCLUDE to speed-up taskhash on directories

Quoted 5 lines · Aníbal Limón

The new BB_SIGNATURE_LOCAL_DIRS_EXCLUDE allows you to specify a list of directories to exclude when making taskhash, our specific case is using SRC_URI that points local VCS directory.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

In OE-Core this variable could be set by default to:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = ".cvs .git .svn"

That should be:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = "CVS .git .svn"

Quoted 7 lines

So I will change to,

+ self.localdirsexclude = (data.getVar("BB_SIGNATURE_LOCAL_DIRS_EXCLUDE") or "CVS .git .svn").split()

Any other directory to add it?

Replying myself...

What about add all VCS directories that we support in fetcher.

Quoted 11 lines

Cheers,
Anibal

Quoted 6 lines
Quoted 2 lines

I like the approach. perhaps a sane default would be nice.

//Peter

#6 lore raw

Regarding some comments in PATCHv2 where default value was set [1], I agree that this patch will be better and then set default value
in oe-core.

[1]
http://lists.openembedded.org/pipermail/bitbake-devel/2019-November/020519.html

Quoted 58 lines · Anibal Limon
Quoted 29 lines · Anibal Limon
Quoted 16 lines · Peter Kjellerstedt
Quoted 16 lines

-----Original Message-----
From: [email protected] <bitbake-devel- [email protected]> On Behalf Of Khem Raj
Sent: den 14 november 2019 03:55
To: Aníbal Limón <[email protected]>
Cc: bitbake-devel <[email protected]>
Subject: Re: [bitbake-devel] [PATCH] lib/bb: Add BB_SIGNATURE_LOCAL_DIRS_EXCLUDE to speed-up taskhash on directories

Quoted 5 lines · Aníbal Limón

The new BB_SIGNATURE_LOCAL_DIRS_EXCLUDE allows you to specify a list of directories to exclude when making taskhash, our specific case is using SRC_URI that points local VCS directory.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

In OE-Core this variable could be set by default to:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = ".cvs .git .svn"

That should be:

BB_SIGNATURE_LOCAL_DIRS_EXCLUDE = "CVS .git .svn"

Quoted 7 lines

So I will change to,

+ self.localdirsexclude = (data.getVar("BB_SIGNATURE_LOCAL_DIRS_EXCLUDE") or "CVS .git .svn").split()

Any other directory to add it?

Replying myself...

What about add all VCS directories that we support in fetcher.

Quoted 11 lines

Cheers,
Anibal

Quoted 6 lines
Quoted 2 lines

I like the approach. perhaps a sane default would be nice.

//Peter