Skip to content
This repository was archived by the owner on Feb 4, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 33 additions & 34 deletions clcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ def printStatistics(cache):
called w/ multiple sources : {}
called w/ PCH : {}""".strip()

with cache.statistics as stats, cache.configuration as cfg:
with cache.statistics.lock, cache.statistics as stats, cache.configuration as cfg:
print(template.format(
str(cache),
stats.currentCacheSize(),
Expand Down Expand Up @@ -1665,35 +1665,34 @@ def processSingleSource(compiler, cmdLine, sourceFile, objectFile, environment):
def processDirect(cache, objectFile, compiler, cmdLine, sourceFile):
manifestHash = ManifestRepository.getManifestHash(compiler, cmdLine, sourceFile)
manifestHit = None
manifest = cache.getManifest(manifestHash)
if manifest:
for entryIndex, entry in enumerate(manifest.entries()):
# NOTE: command line options already included in hash for manifest name
try:
includesContentHash = ManifestRepository.getIncludesContentHashForFiles(
[expandBasedirPlaceholder(path) for path in entry.includeFiles])

if entry.includesContentHash == includesContentHash:
cachekey = entry.objectHash
assert cachekey is not None
if entryIndex > 0:
# Move manifest entry to the top of the entries in the manifest
with cache.manifestLockFor(manifestHash):
manifest = cache.getManifest(manifestHash) or Manifest()
with cache.manifestLockFor(manifestHash):
manifest = cache.getManifest(manifestHash)
if manifest:
for entryIndex, entry in enumerate(manifest.entries()):
# NOTE: command line options already included in hash for manifest name
try:
includesContentHash = ManifestRepository.getIncludesContentHashForFiles(
[expandBasedirPlaceholder(path) for path in entry.includeFiles])

if entry.includesContentHash == includesContentHash:
cachekey = entry.objectHash
assert cachekey is not None
if entryIndex > 0:
# Move manifest entry to the top of the entries in the manifest
manifest.touchEntry(cachekey)
cache.setManifest(manifestHash, manifest)

manifestHit = True
with cache.lockFor(cachekey):
if cache.hasEntry(cachekey):
return processCacheHit(cache, objectFile, cachekey)
manifestHit = True
with cache.lockFor(cachekey):
if cache.hasEntry(cachekey):
return processCacheHit(cache, objectFile, cachekey)

except IncludeNotFoundException:
pass
except IncludeNotFoundException:
pass

unusableManifestMissReason = Statistics.registerHeaderChangedMiss
else:
unusableManifestMissReason = Statistics.registerSourceChangedMiss
unusableManifestMissReason = Statistics.registerHeaderChangedMiss
else:
unusableManifestMissReason = Statistics.registerSourceChangedMiss

if manifestHit is None:
stripIncludes = False
Expand All @@ -1706,21 +1705,21 @@ def processDirect(cache, objectFile, compiler, cmdLine, sourceFile):
includePaths, compilerOutput = parseIncludesSet(compilerResult[1], sourceFile, stripIncludes)
compilerResult = (compilerResult[0], compilerOutput, compilerResult[2])

if manifestHit is not None:
return ensureArtifactsExist(cache, cachekey, unusableManifestMissReason,
objectFile, compilerResult)
with cache.manifestLockFor(manifestHash):
if manifestHit is not None:
return ensureArtifactsExist(cache, cachekey, unusableManifestMissReason,
objectFile, compilerResult)

entry = createManifestEntry(manifestHash, includePaths)
cachekey = entry.objectHash
entry = createManifestEntry(manifestHash, includePaths)
cachekey = entry.objectHash

def addManifest():
with cache.manifestLockFor(manifestHash):
def addManifest():
manifest = cache.getManifest(manifestHash) or Manifest()
manifest.addEntry(entry)
cache.setManifest(manifestHash, manifest)

return ensureArtifactsExist(cache, cachekey, unusableManifestMissReason,
objectFile, compilerResult, addManifest)
return ensureArtifactsExist(cache, cachekey, unusableManifestMissReason,
objectFile, compilerResult, addManifest)


def processNoDirect(cache, objectFile, compiler, cmdLine, environment):
Expand Down