JPS: Fix updating cache format version for rebuilt targets by removing i/o optimization
Problem: previously, format-version.txt file was deleted while cleaning
target output on rebuild. Since directory was deleted, cache
attributesDiff stored in memory was not updated. This causes that on
saveExpectedStateIfNeeded does nothing.
The right way to fix it is move cache version format diff into
AbstractIncrementalCache, and override `clean()` method. But this is
hard to do for lookup storage, since used compilers set (jvm/js) will
known only after context init. This can be done by moving `expected`
attributes out of manager, but this is huge change for small benefit.
So, the optimal way for now is to write version for each build, even if
it is not changed.
#KT-27044 Fixed
Original commit: 5232f080d6
This commit is contained in:
@@ -96,7 +96,7 @@ class KotlinChunk internal constructor(val context: KotlinCompileContext, val ta
|
||||
context.ensureLookupsCacheAttributesSaved()
|
||||
|
||||
targets.forEach {
|
||||
it.initialLocalCacheAttributesDiff.saveExpectedIfNeeded()
|
||||
it.initialLocalCacheAttributesDiff.manager.writeVersion()
|
||||
}
|
||||
|
||||
val serializedMetaInfo = representativeTarget.buildMetaInfoFactory.serializeToString(compilerArguments)
|
||||
|
||||
@@ -149,7 +149,7 @@ class KotlinCompileContext(val jpsContext: CompileContext) {
|
||||
*/
|
||||
fun ensureLookupsCacheAttributesSaved() {
|
||||
if (lookupAttributesSaved.compareAndSet(false, true)) {
|
||||
initialLookupsCacheStateDiff.saveExpectedIfNeeded()
|
||||
initialLookupsCacheStateDiff.manager.writeVersion()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ class KotlinCompileContext(val jpsContext: CompileContext) {
|
||||
private fun clearLookupCache() {
|
||||
KotlinBuilder.LOG.info("Clearing lookup cache")
|
||||
dataManager.cleanLookupStorage(KotlinBuilder.LOG)
|
||||
initialLookupsCacheStateDiff.saveExpectedIfNeeded()
|
||||
initialLookupsCacheStateDiff.manager.writeVersion()
|
||||
}
|
||||
|
||||
fun cleanupCaches() {
|
||||
|
||||
+3
-3
@@ -47,12 +47,12 @@ class CompositeLookupsCacheAttributesManager(
|
||||
return CompositeLookupsCacheAttributes(version.version, components)
|
||||
}
|
||||
|
||||
override fun writeActualVersion(values: CompositeLookupsCacheAttributes?) {
|
||||
override fun writeVersion(values: CompositeLookupsCacheAttributes?) {
|
||||
if (values == null) {
|
||||
versionManager.writeActualVersion(null)
|
||||
versionManager.writeVersion(null)
|
||||
actualComponentsFile.delete()
|
||||
} else {
|
||||
versionManager.writeActualVersion(CacheVersion(values.version))
|
||||
versionManager.writeVersion(CacheVersion(values.version))
|
||||
|
||||
actualComponentsFile.parentFile.mkdirs()
|
||||
actualComponentsFile.writeText(values.components.joinToString("\n"))
|
||||
|
||||
Reference in New Issue
Block a user