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()
buildCache(
cachePath = outputFilePath,
project = projectJs,
mainModule = mainModule,
analyzer = AnalyzerWithCompilerReport(config.configuration),
configuration = config.configuration,
dependencies = libraries,
friendDependencies = friendLibraries,
icCache = checkCaches(libraries, icCaches, skipLib = mainModule.libPath)
)
messageCollector.report(INFO, "IC cache building duration: ${System.currentTimeMillis() - start}ms")
if (buildCache(
cachePath = outputFilePath,
project = projectJs,
mainModule = mainModule,
analyzer = AnalyzerWithCompilerReport(config.configuration),
configuration = config.configuration,
dependencies = libraries,
friendDependencies = friendLibraries,
icCache = checkCaches(libraries, icCaches, skipLib = mainModule.libPath)
)
) {
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
}
@@ -21,6 +21,7 @@ import kotlin.random.nextULong
private val compilerVersion = Random.nextULong()
// TODO more parameters for lowerings
// Returns true if caches were built. False if caches were up-to-date.
fun buildCache(
cachePath: String,
project: Project,
@@ -32,7 +33,7 @@ fun buildCache(
exportedDeclarations: Set<FqName> = emptySet(),
forceClean: Boolean = false,
icCache: IcCacheInfo = IcCacheInfo.EMPTY,
) {
): Boolean {
val dependencyHashes = dependencies.mapNotNull {
val path = File(it).canonicalPath
icCache.md5[path]
@@ -42,7 +43,7 @@ fun buildCache(
if (!forceClean) {
val oldCacheInfo = CacheInfo.load(cachePath)
if (oldCacheInfo != null && md5 == oldCacheInfo.md5) return
if (oldCacheInfo != null && md5 == oldCacheInfo.md5) return false
}
val icDir = File(cachePath)
@@ -54,6 +55,8 @@ fun buildCache(
icData.writeTo(File(cachePath))
CacheInfo(cachePath, mainModule.libPath, md5).save()
return true
}
private fun File.md5(additional: Iterable<ULong> = emptyList()): ULong {