From: "Joshua Watt" <JPEWhacker@gmail.com>
To: bitbake-devel@lists.openembedded.org
Cc: Joshua Watt <JPEWhacker@gmail.com>
Subject: [bitbake-devel][PATCH 5/8] bitbake: cache: Improve logging
Date: Mon, 1 Jun 2020 15:28:04 -0500 [thread overview]
Message-ID: <20200601202807.26357-6-JPEWhacker@gmail.com> (raw)
In-Reply-To: <20200601202807.26357-1-JPEWhacker@gmail.com>
Improves the logging of Cache objects by prefixing the log messages with
the multiconfig name of the cache, so as to distinguish between multiple
instances of the class. Also adds a more log messages.
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
bitbake/lib/bb/cache.py | 65 ++++++++++++++++++++++-------------------
1 file changed, 35 insertions(+), 30 deletions(-)
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 954418384b..b34bfa9b5a 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -21,6 +21,7 @@ import logging
import pickle
from collections import defaultdict, Mapping
import bb.utils
+from bb import PrefixLoggerAdapter
import re
logger = logging.getLogger("BitBake.Cache")
@@ -365,6 +366,7 @@ class Cache(NoCache):
# It will be used later for deciding whether we
# need extra cache file dump/load support
self.mc = mc
+ self.logger = PrefixLoggerAdapter("Cache: %s: " % (mc if mc else "default"), logger)
self.caches_array = caches_array
self.cachedir = data.getVar("CACHE")
self.clean = set()
@@ -377,8 +379,8 @@ class Cache(NoCache):
if self.cachedir in [None, '']:
self.has_cache = False
- logger.info("Not using a cache. "
- "Set CACHE = <directory> to enable.")
+ self.logger.info("Not using a cache. "
+ "Set CACHE = <directory> to enable.")
return
self.has_cache = True
@@ -394,21 +396,23 @@ class Cache(NoCache):
self.cachefile = self.getCacheFile("bb_cache.dat")
- logger.debug(1, "Cache dir: %s", self.cachedir)
+ self.logger.debug(1, "Cache dir: %s", self.cachedir)
bb.utils.mkdirhier(self.cachedir)
cache_ok = True
if self.caches_array:
for cache_class in self.caches_array:
cachefile = self.getCacheFile(cache_class.cachefile)
- cache_ok = cache_ok and os.path.exists(cachefile)
+ cache_exists = os.path.exists(cachefile)
+ self.logger.debug(2, "Checking if %s exists: %r", cachefile, cache_exists)
+ cache_ok = cache_ok and cache_exists
cache_class.init_cacheData(self)
if cache_ok:
loaded = self.load_cachefile(progress)
elif os.path.isfile(self.cachefile):
- logger.info("Out of date cache found, rebuilding...")
+ self.logger.info("Out of date cache found, rebuilding...")
else:
- logger.debug(1, "Cache file %s not found, building..." % self.cachefile)
+ self.logger.debug(1, "Cache file %s not found, building..." % self.cachefile)
# We don't use the symlink, its just for debugging convinience
if self.mc:
@@ -447,7 +451,7 @@ class Cache(NoCache):
for cache_class in self.caches_array:
cachefile = self.getCacheFile(cache_class.cachefile)
- logger.debug(1, 'Loading cache file: %s' % cachefile)
+ self.logger.debug(1, 'Loading cache file: %s' % cachefile)
with open(cachefile, "rb") as cachefile:
pickled = pickle.Unpickler(cachefile)
# Check cache version information
@@ -455,14 +459,14 @@ class Cache(NoCache):
cache_ver = pickled.load()
bitbake_ver = pickled.load()
except Exception:
- logger.info('Invalid cache, rebuilding...')
+ self.logger.info('Invalid cache, rebuilding...')
return
if cache_ver != __cache_version__:
- logger.info('Cache version mismatch, rebuilding...')
+ self.logger.info('Cache version mismatch, rebuilding...')
return
elif bitbake_ver != bb.__version__:
- logger.info('Bitbake version mismatch, rebuilding...')
+ self.logger.info('Bitbake version mismatch, rebuilding...')
return
# Load the rest of the cache file
@@ -494,7 +498,7 @@ class Cache(NoCache):
def parse(self, filename, appends):
"""Parse the specified filename, returning the recipe information"""
- logger.debug(1, "Parsing %s", filename)
+ self.logger.debug(1, "Parsing %s", filename)
infos = []
datastores = self.load_bbfile(filename, appends)
depends = []
@@ -548,7 +552,7 @@ class Cache(NoCache):
cached, infos = self.load(fn, appends)
for virtualfn, info_array in infos:
if info_array[0].skipped:
- logger.debug(1, "Skipping %s: %s", virtualfn, info_array[0].skipreason)
+ self.logger.debug(1, "Skipping %s: %s", virtualfn, info_array[0].skipreason)
skipped += 1
else:
self.add_info(virtualfn, info_array, cacheData, not cached)
@@ -584,21 +588,21 @@ class Cache(NoCache):
# File isn't in depends_cache
if not fn in self.depends_cache:
- logger.debug(2, "Cache: %s is not cached", fn)
+ self.logger.debug(2, "%s is not cached", fn)
return False
mtime = bb.parse.cached_mtime_noerror(fn)
# Check file still exists
if mtime == 0:
- logger.debug(2, "Cache: %s no longer exists", fn)
+ self.logger.debug(2, "%s no longer exists", fn)
self.remove(fn)
return False
info_array = self.depends_cache[fn]
# Check the file's timestamp
if mtime != info_array[0].timestamp:
- logger.debug(2, "Cache: %s changed", fn)
+ self.logger.debug(2, "%s changed", fn)
self.remove(fn)
return False
@@ -609,14 +613,14 @@ class Cache(NoCache):
fmtime = bb.parse.cached_mtime_noerror(f)
# Check if file still exists
if old_mtime != 0 and fmtime == 0:
- logger.debug(2, "Cache: %s's dependency %s was removed",
- fn, f)
+ self.logger.debug(2, "%s's dependency %s was removed",
+ fn, f)
self.remove(fn)
return False
if (fmtime != old_mtime):
- logger.debug(2, "Cache: %s's dependency %s changed",
- fn, f)
+ self.logger.debug(2, "%s's dependency %s changed",
+ fn, f)
self.remove(fn)
return False
@@ -632,14 +636,14 @@ class Cache(NoCache):
continue
f, exist = f.split(":")
if (exist == "True" and not os.path.exists(f)) or (exist == "False" and os.path.exists(f)):
- logger.debug(2, "Cache: %s's file checksum list file %s changed",
- fn, f)
+ self.logger.debug(2, "%s's file checksum list file %s changed",
+ fn, f)
self.remove(fn)
return False
if tuple(appends) != tuple(info_array[0].appends):
- logger.debug(2, "Cache: appends for %s changed", fn)
- logger.debug(2, "%s to %s" % (str(appends), str(info_array[0].appends)))
+ self.logger.debug(2, "appends for %s changed", fn)
+ self.logger.debug(2, "%s to %s" % (str(appends), str(info_array[0].appends)))
self.remove(fn)
return False
@@ -648,10 +652,10 @@ class Cache(NoCache):
virtualfn = variant2virtual(fn, cls)
self.clean.add(virtualfn)
if virtualfn not in self.depends_cache:
- logger.debug(2, "Cache: %s is not cached", virtualfn)
+ self.logger.debug(2, "%s is not cached", virtualfn)
invalid = True
elif len(self.depends_cache[virtualfn]) != len(self.caches_array):
- logger.debug(2, "Cache: Extra caches missing for %s?" % virtualfn)
+ self.logger.debug(2, "Extra caches missing for %s?" % virtualfn)
invalid = True
# If any one of the variants is not present, mark as invalid for all
@@ -659,10 +663,10 @@ class Cache(NoCache):
for cls in info_array[0].variants:
virtualfn = variant2virtual(fn, cls)
if virtualfn in self.clean:
- logger.debug(2, "Cache: Removing %s from cache", virtualfn)
+ self.logger.debug(2, "Removing %s from cache", virtualfn)
self.clean.remove(virtualfn)
if fn in self.clean:
- logger.debug(2, "Cache: Marking %s as not clean", fn)
+ self.logger.debug(2, "Marking %s as not clean", fn)
self.clean.remove(fn)
return False
@@ -675,10 +679,10 @@ class Cache(NoCache):
Called from the parser in error cases
"""
if fn in self.depends_cache:
- logger.debug(1, "Removing %s from cache", fn)
+ self.logger.debug(1, "Removing %s from cache", fn)
del self.depends_cache[fn]
if fn in self.clean:
- logger.debug(1, "Marking %s as unclean", fn)
+ self.logger.debug(1, "Marking %s as unclean", fn)
self.clean.remove(fn)
def sync(self):
@@ -691,12 +695,13 @@ class Cache(NoCache):
return
if self.cacheclean:
- logger.debug(2, "Cache is clean, not saving.")
+ self.logger.debug(2, "Cache is clean, not saving.")
return
for cache_class in self.caches_array:
cache_class_name = cache_class.__name__
cachefile = self.getCacheFile(cache_class.cachefile)
+ self.logger.debug(2, "Writing %s", cachefile)
with open(cachefile, "wb") as f:
p = pickle.Pickler(f, pickle.HIGHEST_PROTOCOL)
p.dump(__cache_version__)
--
2.17.1
next prev parent reply other threads:[~2020-06-01 20:28 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-01 20:27 [bitbake-devel][PATCH 0/8] Add support for per-multiconfig BBMASK Joshua Watt
2020-06-01 20:28 ` [bitbake-devel][PATCH 1/8] bitbake: cooker: Split file collections per multiconfig Joshua Watt
2020-06-01 20:28 ` [bitbake-devel][PATCH 2/8] bitbake: cache: Use multiconfig aware caches Joshua Watt
2020-06-01 20:28 ` [bitbake-devel][PATCH 3/8] bitbake: lib: Add support for Logging Adapters Joshua Watt
2020-06-01 20:28 ` [bitbake-devel][PATCH 4/8] bitbake: lib: Add PrefixLoggerAdapter helper Joshua Watt
2020-06-01 20:28 ` Joshua Watt [this message]
2020-06-01 20:28 ` [bitbake-devel][PATCH 6/8] bitbake: cache: Cache size optimization Joshua Watt
2020-06-01 20:28 ` [bitbake-devel][PATCH 7/8] bitbake: tests: Add tests for BBMASK in multiconfig Joshua Watt
2020-06-01 20:28 ` [bitbake-devel][PATCH 8/8] bitbake: command: Move split_mc_pn to runqueue Joshua Watt
2020-06-01 21:49 ` [bitbake-devel][PATCH v2 0/8] Add support for per-multiconfig BBMASK Joshua Watt
2020-06-01 21:49 ` [bitbake-devel][PATCH v2 1/8] bitbake: cooker: Split file collections per multiconfig Joshua Watt
2020-06-01 21:49 ` [bitbake-devel][PATCH v2 2/8] bitbake: cache: Use multiconfig aware caches Joshua Watt
2020-06-01 21:49 ` [bitbake-devel][PATCH v2 3/8] bitbake: lib: Add support for Logging Adapters Joshua Watt
2020-06-01 21:49 ` [bitbake-devel][PATCH v2 4/8] bitbake: lib: Add PrefixLoggerAdapter helper Joshua Watt
2020-06-01 21:49 ` [bitbake-devel][PATCH v2 5/8] bitbake: cache: Improve logging Joshua Watt
2020-06-01 21:49 ` [bitbake-devel][PATCH v2 6/8] bitbake: cache: Cache size optimization Joshua Watt
2020-06-01 21:49 ` [bitbake-devel][PATCH v2 7/8] bitbake: tests: Add tests for BBMASK in multiconfig Joshua Watt
2020-06-01 21:49 ` [bitbake-devel][PATCH v2 8/8] bitbake: command: Move split_mc_pn to runqueue Joshua Watt
2020-06-03 2:53 ` [OE-core][PATCH v3 0/8] Add support for per-multiconfig BBMASK Joshua Watt
2020-06-03 2:53 ` [OE-core][PATCH v3 1/8] bitbake: cooker: Split file collections per multiconfig Joshua Watt
2020-06-03 2:53 ` [OE-core][PATCH v3 2/8] bitbake: cache: Use multiconfig aware caches Joshua Watt
2020-06-03 2:54 ` [OE-core][PATCH v3 3/8] bitbake: lib: Add support for Logging Adapters Joshua Watt
2020-06-03 2:54 ` [OE-core][PATCH v3 4/8] bitbake: lib: Add PrefixLoggerAdapter helper Joshua Watt
2020-06-04 21:00 ` Richard Purdie
2020-06-03 2:54 ` [OE-core][PATCH v3 5/8] bitbake: cache: Improve logging Joshua Watt
2020-06-03 2:54 ` [OE-core][PATCH v3 6/8] bitbake: cache: Cache size optimization Joshua Watt
2020-06-03 2:54 ` [OE-core][PATCH v3 7/8] bitbake: tests: Add tests for BBMASK in multiconfig Joshua Watt
2020-06-03 2:54 ` [OE-core][PATCH v3 8/8] bitbake: command: Move split_mc_pn to runqueue Joshua Watt
2020-06-05 1:53 ` [bitbake-devel][PATCH v4 0/8] Add support for per-multiconfig BBMASK Joshua Watt
2020-06-05 1:53 ` [bitbake-devel][PATCH v4 1/8] bitbake: cooker: Split file collections per multiconfig Joshua Watt
2020-06-05 1:53 ` [bitbake-devel][PATCH v4 2/8] bitbake: cache: Use multiconfig aware caches Joshua Watt
2020-06-05 1:53 ` [bitbake-devel][PATCH v4 3/8] bitbake: lib: Add support for Logging Adapters Joshua Watt
2020-06-05 1:53 ` [bitbake-devel][PATCH v4 4/8] bitbake: lib: Add PrefixLoggerAdapter helper Joshua Watt
2020-06-05 1:53 ` [bitbake-devel][PATCH v4 5/8] bitbake: cache: Improve logging Joshua Watt
2020-06-05 1:53 ` [bitbake-devel][PATCH v4 6/8] bitbake: cache: Cache size optimization Joshua Watt
2020-06-05 1:53 ` [bitbake-devel][PATCH v4 7/8] bitbake: tests: Add tests for BBMASK in multiconfig Joshua Watt
2020-06-05 1:53 ` [bitbake-devel][PATCH v4 8/8] bitbake: command: Move split_mc_pn to runqueue Joshua Watt
2020-06-05 7:29 ` [bitbake-devel][PATCH v4 0/8] Add support for per-multiconfig BBMASK Alejandro Hernandez
2020-06-05 15:22 ` Joshua Watt
2020-06-05 20:05 ` Richard Purdie
2020-06-06 3:15 ` [bitbake-devel][PATCH v5 " Joshua Watt
2020-06-06 3:15 ` [bitbake-devel][PATCH v5 1/8] bitbake: cooker: Split file collections per multiconfig Joshua Watt
2020-06-06 3:15 ` [bitbake-devel][PATCH v5 2/8] bitbake: cache: Use multiconfig aware caches Joshua Watt
2020-06-06 3:15 ` [bitbake-devel][PATCH v5 3/8] bitbake: lib: Add support for Logging Adapters Joshua Watt
2020-06-06 3:15 ` [bitbake-devel][PATCH v5 4/8] bitbake: lib: Add PrefixLoggerAdapter helper Joshua Watt
2020-06-06 3:15 ` [bitbake-devel][PATCH v5 5/8] bitbake: cache: Improve logging Joshua Watt
2020-06-06 3:15 ` [bitbake-devel][PATCH v5 6/8] bitbake: cache: Cache size optimization Joshua Watt
2020-06-06 3:15 ` [bitbake-devel][PATCH v5 7/8] bitbake: tests: Add tests for BBMASK in multiconfig Joshua Watt
2020-06-06 3:15 ` [bitbake-devel][PATCH v5 8/8] bitbake: command: Move split_mc_pn to runqueue Joshua Watt
2020-06-08 20:32 ` [bitbake-devel][PATCH v5 0/8] Add support for per-multiconfig BBMASK Richard Purdie
2020-06-03 3:02 ` ✗ patchtest: failure for " Patchwork
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=20200601202807.26357-6-JPEWhacker@gmail.com \
--to=jpewhacker@gmail.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.