KT-45777: Count cache misses when loading classpath snapshot

to get more insights into the build performance of that step.

^KT-45777 In Progress
This commit is contained in:
Hung Nguyen
2022-03-24 20:32:07 +00:00
committed by teamcity
parent f23e66a6e2
commit bd8f49c5d6
7 changed files with 40 additions and 31 deletions
@@ -91,15 +91,15 @@ abstract class ClasspathEntrySnapshotTransform : TransformAction<ClasspathEntryS
metrics.measure(BuildTime.SAVE_CLASSPATH_ENTRY_SNAPSHOT) {
ClasspathEntrySnapshotExternalizer.saveToFile(snapshotOutputFile, snapshot)
}
}
metrics.addMetric(BuildPerformanceMetric.CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT, 1)
if (classpathEntryInputDirOrJar.extension.equals("jar", ignoreCase = true)) {
metrics.addMetric(BuildPerformanceMetric.JAR_CLASSPATH_ENTRY_SIZE, classpathEntryInputDirOrJar.length())
metrics.addMetric(BuildPerformanceMetric.JAR_CLASSPATH_ENTRY_SNAPSHOT_SIZE, snapshotOutputFile.length())
} else {
// Only compute the size of the snapshot, not the size of the input directory as walking the file tree has a small overhead
metrics.addMetric(BuildPerformanceMetric.DIRECTORY_CLASSPATH_ENTRY_SNAPSHOT_SIZE, snapshotOutputFile.length())
}
metrics.addMetric(BuildPerformanceMetric.CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT, 1)
if (classpathEntryInputDirOrJar.extension.equals("jar", ignoreCase = true)) {
metrics.addMetric(BuildPerformanceMetric.JAR_CLASSPATH_ENTRY_SIZE, classpathEntryInputDirOrJar.length())
metrics.addMetric(BuildPerformanceMetric.JAR_CLASSPATH_ENTRY_SNAPSHOT_SIZE, snapshotOutputFile.length())
} else {
// Only compute the size of the snapshot, not the size of the input directory as walking the file tree has a small overhead
metrics.addMetric(BuildPerformanceMetric.DIRECTORY_CLASSPATH_ENTRY_SNAPSHOT_SIZE, snapshotOutputFile.length())
}
}
}
@@ -282,7 +282,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
}
).disallowChanges()
task.taskBuildCacheableOutputDirectory.value(getKotlinBuildDir(task).map { it.dir("cacheable") }).disallowChanges()
task.taskBuildLocalStateDirectory.value(getKotlinBuildDir(task).map { it.dir("localstate") }).disallowChanges()
task.taskBuildLocalStateDirectory.value(getKotlinBuildDir(task).map { it.dir("local-state") }).disallowChanges()
task.localStateDirectories.from(task.taskBuildLocalStateDirectory).disallowChanges()
@@ -292,7 +292,7 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
private fun getKotlinBuildDir(task: T): Provider<Directory> =
task.project.layout.buildDirectory.dir("$KOTLIN_BUILD_DIR_NAME/${task.name}")
protected open fun getClasspathSnapshotDir(task: T): Provider<Directory> =
protected fun getClasspathSnapshotDir(task: T): Provider<Directory> =
getKotlinBuildDir(task).map { it.dir("classpath-snapshot") }
}