From 6ca23dce870dfb74a70d876cb681ed84f931abd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Si=C3=B1uela?= Date: Mon, 15 Aug 2016 18:11:12 +0200 Subject: [PATCH] Don't hold the cache lock while computing the manifest hash for the current object --- clcache.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/clcache.py b/clcache.py index f18acdd1..b30346df 100644 --- a/clcache.py +++ b/clcache.py @@ -1537,35 +1537,36 @@ def processDirect(cache, objectFile, compiler, cmdLine, sourceFile): baseDir = normalizeBaseDir(os.environ.get('CLCACHE_BASEDIR')) manifestHash = ManifestRepository.getManifestHash(compiler, cmdLine, sourceFile) manifestSection = cache.manifestRepository.section(manifestHash) + createNewManifest = False with cache.lock: - createNewManifest = False manifest = manifestSection.getManifest(manifestHash) - if manifest is not None: - # NOTE: command line options already included in hash for manifest name - try: - includesContentHash = ManifestRepository.getIncludesContentHashForFiles({ - expandBasedirPlaceholder(path, baseDir):contentHash - for path, contentHash in manifest.includeFiles.items() - }) - - cachekey = manifest.includesContentToObjectMap.get(includesContentHash) - assert cachekey is not None + if manifest is not None: + # NOTE: command line options already included in hash for manifest name + try: + includesContentHash = ManifestRepository.getIncludesContentHashForFiles({ + expandBasedirPlaceholder(path, baseDir):contentHash + for path, contentHash in manifest.includeFiles.items() + }) + + cachekey = manifest.includesContentToObjectMap.get(includesContentHash) + assert cachekey is not None + with cache.lock: if cache.compilerArtifactsRepository.section(cachekey).hasEntry(cachekey): return processCacheHit(cache, objectFile, cachekey) else: postProcessing = lambda compilerResult: postprocessObjectEvicted( cache, objectFile, cachekey, compilerResult) - except IncludeChangedException: - createNewManifest = True - postProcessing = lambda compilerResult: postprocessHeaderChangedMiss( - cache, objectFile, manifestSection, manifestHash, sourceFile, compilerResult, stripIncludes) - except IncludeNotFoundException: - # register nothing. This is probably just a compile error - postProcessing = None - else: + except IncludeChangedException: createNewManifest = True - postProcessing = lambda compilerResult: postprocessNoManifestMiss( + postProcessing = lambda compilerResult: postprocessHeaderChangedMiss( cache, objectFile, manifestSection, manifestHash, sourceFile, compilerResult, stripIncludes) + except IncludeNotFoundException: + # register nothing. This is probably just a compile error + postProcessing = None + else: + createNewManifest = True + postProcessing = lambda compilerResult: postprocessNoManifestMiss( + cache, objectFile, manifestSection, manifestHash, sourceFile, compilerResult, stripIncludes) if createNewManifest: stripIncludes = False