JS IR IC: report cache validataion duration when up-to-date

This commit is contained in:
Anton Bannykh
2021-07-19 15:31:07 +03:00
committed by teamcityserver
parent 4cee44cd6e
commit a7549be95e
2 changed files with 20 additions and 14 deletions
@@ -201,18 +201,21 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
} }
val start = System.currentTimeMillis() val start = System.currentTimeMillis()
buildCache( if (buildCache(
cachePath = outputFilePath, cachePath = outputFilePath,
project = projectJs, project = projectJs,
mainModule = mainModule, mainModule = mainModule,
analyzer = AnalyzerWithCompilerReport(config.configuration), analyzer = AnalyzerWithCompilerReport(config.configuration),
configuration = config.configuration, configuration = config.configuration,
dependencies = libraries, dependencies = libraries,
friendDependencies = friendLibraries, friendDependencies = friendLibraries,
icCache = checkCaches(libraries, icCaches, skipLib = mainModule.libPath) icCache = checkCaches(libraries, icCaches, skipLib = mainModule.libPath)
) )
) {
messageCollector.report(INFO, "IC cache building duration: ${System.currentTimeMillis() - start}ms") messageCollector.report(INFO, "IC cache building duration: ${System.currentTimeMillis() - start}ms")
} else {
messageCollector.report(INFO, "IC cache up-to-date check duration: ${System.currentTimeMillis() - start}ms")
}
return OK return OK
} }
@@ -21,6 +21,7 @@ import kotlin.random.nextULong
private val compilerVersion = Random.nextULong() private val compilerVersion = Random.nextULong()
// TODO more parameters for lowerings // TODO more parameters for lowerings
// Returns true if caches were built. False if caches were up-to-date.
fun buildCache( fun buildCache(
cachePath: String, cachePath: String,
project: Project, project: Project,
@@ -32,7 +33,7 @@ fun buildCache(
exportedDeclarations: Set<FqName> = emptySet(), exportedDeclarations: Set<FqName> = emptySet(),
forceClean: Boolean = false, forceClean: Boolean = false,
icCache: IcCacheInfo = IcCacheInfo.EMPTY, icCache: IcCacheInfo = IcCacheInfo.EMPTY,
) { ): Boolean {
val dependencyHashes = dependencies.mapNotNull { val dependencyHashes = dependencies.mapNotNull {
val path = File(it).canonicalPath val path = File(it).canonicalPath
icCache.md5[path] icCache.md5[path]
@@ -42,7 +43,7 @@ fun buildCache(
if (!forceClean) { if (!forceClean) {
val oldCacheInfo = CacheInfo.load(cachePath) val oldCacheInfo = CacheInfo.load(cachePath)
if (oldCacheInfo != null && md5 == oldCacheInfo.md5) return if (oldCacheInfo != null && md5 == oldCacheInfo.md5) return false
} }
val icDir = File(cachePath) val icDir = File(cachePath)
@@ -54,6 +55,8 @@ fun buildCache(
icData.writeTo(File(cachePath)) icData.writeTo(File(cachePath))
CacheInfo(cachePath, mainModule.libPath, md5).save() CacheInfo(cachePath, mainModule.libPath, md5).save()
return true
} }
private fun File.md5(additional: Iterable<ULong> = emptyList()): ULong { private fun File.md5(additional: Iterable<ULong> = emptyList()): ULong {