repos: Cache for build report

This commit is contained in:
Ivan A. Melnikov 2023-10-24 18:29:10 +04:00
parent 66ce9a190c
commit ad19973427

View File

@ -433,12 +433,21 @@ def _is_build_kind(kind):
return kind in (_BUILDREQ, _BUILD_UNMET)
__BUILD_REPORT_CACHE = {}
def build_report(from_repo, to_repo, source_name, ignore=(), prefer=()):
"""Build report for one source, by name
Returns an iterable over tuples (kind, dep, provider).
"""
LOG.debug("raw Build report for %s", source_name)
cache_key = (from_repo.name, to_repo.name, source_name,
frozenset(ignore), frozenset(prefer))
cached_result = __BUILD_REPORT_CACHE.get(cache_key)
if cached_result is not None:
if cached_result.is_valid([from_repo, to_repo]):
return cached_result
LOG.debug("Building build report: %s", cache_key)
# XXX: assumes from_repo is x86_64
assert from_repo.bits == 64
@ -497,7 +506,9 @@ def build_report(from_repo, to_repo, source_name, ignore=(), prefer=()):
LOG.info("Using preferred providers: %s", preferred)
providers = preferred
result.update((kind, dep, provider) for provider in providers)
return TripletReport([from_repo, to_repo], result)
the_report = TripletReport([from_repo, to_repo], result)
__BUILD_REPORT_CACHE[cache_key] = the_report
return the_report
def _src_name(source):