diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-21 19:29:17 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-01-24 21:59:44 +0000 |
commit | 4a94cf21c5538232a4ca32cd249794933e31818b (patch) | |
tree | c780df05f0289cac9d8fce24d96ac5665a9d14c4 | |
parent | ae1da8b75c6e12642c4a08accd21c764541b86c9 (diff) | |
download | poky-4a94cf21c5538232a4ca32cd249794933e31818b.tar.gz |
bitbake: cache: Only write files if we have data
By writing the cache files only if there is data to write, we can save a
bit of time.
(Bitbake rev: abeff1f80bb1c690b92d535d472dff9df7a56067)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | bitbake/lib/bb/cache.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py index ee924b2d2b..8db4e47674 100644 --- a/bitbake/lib/bb/cache.py +++ b/bitbake/lib/bb/cache.py | |||
@@ -873,6 +873,10 @@ class MultiProcessCache(object): | |||
873 | if not self.cachefile: | 873 | if not self.cachefile: |
874 | return | 874 | return |
875 | 875 | ||
876 | have_data = any(self.cachedata_extras) | ||
877 | if not have_data: | ||
878 | return | ||
879 | |||
876 | glf = bb.utils.lockfile(self.cachefile + ".lock", shared=True) | 880 | glf = bb.utils.lockfile(self.cachefile + ".lock", shared=True) |
877 | 881 | ||
878 | i = os.getpid() | 882 | i = os.getpid() |
@@ -907,6 +911,8 @@ class MultiProcessCache(object): | |||
907 | 911 | ||
908 | data = self.cachedata | 912 | data = self.cachedata |
909 | 913 | ||
914 | have_data = False | ||
915 | |||
910 | for f in [y for y in os.listdir(os.path.dirname(self.cachefile)) if y.startswith(os.path.basename(self.cachefile) + '-')]: | 916 | for f in [y for y in os.listdir(os.path.dirname(self.cachefile)) if y.startswith(os.path.basename(self.cachefile) + '-')]: |
911 | f = os.path.join(os.path.dirname(self.cachefile), f) | 917 | f = os.path.join(os.path.dirname(self.cachefile), f) |
912 | try: | 918 | try: |
@@ -921,12 +927,14 @@ class MultiProcessCache(object): | |||
921 | os.unlink(f) | 927 | os.unlink(f) |
922 | continue | 928 | continue |
923 | 929 | ||
930 | have_data = True | ||
924 | self.merge_data(extradata, data) | 931 | self.merge_data(extradata, data) |
925 | os.unlink(f) | 932 | os.unlink(f) |
926 | 933 | ||
927 | with open(self.cachefile, "wb") as f: | 934 | if have_data: |
928 | p = pickle.Pickler(f, -1) | 935 | with open(self.cachefile, "wb") as f: |
929 | p.dump([data, self.__class__.CACHE_VERSION]) | 936 | p = pickle.Pickler(f, -1) |
937 | p.dump([data, self.__class__.CACHE_VERSION]) | ||
930 | 938 | ||
931 | bb.utils.unlockfile(glf) | 939 | bb.utils.unlockfile(glf) |
932 | 940 | ||