Add compiler IRMeasurement to build reports
#KT-65091: Fixed
This commit is contained in:
committed by
Space Team
parent
b4b1c7cd69
commit
090407b7e3
+5
-1
@@ -81,6 +81,10 @@ enum class GradleBuildPerformanceMetric(
|
|||||||
CODE_GENERATED_LINES_NUMBER(parent = COMPILE_ITERATION, "Number of lines for code generation", type = ValueType.NUMBER),
|
CODE_GENERATED_LINES_NUMBER(parent = COMPILE_ITERATION, "Number of lines for code generation", type = ValueType.NUMBER),
|
||||||
ANALYSIS_LPS(parent = COMPILE_ITERATION, "Analysis lines per second", type = ValueType.NUMBER),
|
ANALYSIS_LPS(parent = COMPILE_ITERATION, "Analysis lines per second", type = ValueType.NUMBER),
|
||||||
CODE_GENERATION_LPS(parent = COMPILE_ITERATION, "Code generation lines per second", type = ValueType.NUMBER),
|
CODE_GENERATION_LPS(parent = COMPILE_ITERATION, "Code generation lines per second", type = ValueType.NUMBER),
|
||||||
|
IR_TRANSLATION_LINES_NUMBER(COMPILE_ITERATION, "Compiler IR translation line number", ValueType.NUMBER),
|
||||||
|
IR_LOWERING_LINES_NUMBER(COMPILE_ITERATION, "Compiler IR lowering line number", ValueType.NUMBER),
|
||||||
|
IR_GENERATION_LINES_NUMBER(COMPILE_ITERATION, "Compiler IR generation line number", ValueType.NUMBER),
|
||||||
|
|
||||||
|
|
||||||
// Metrics for the `kotlin.incremental.useClasspathSnapshot` feature
|
// Metrics for the `kotlin.incremental.useClasspathSnapshot` feature
|
||||||
CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT(
|
CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT(
|
||||||
@@ -162,7 +166,7 @@ enum class GradleBuildPerformanceMetric(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val serialVersionUID = 1L
|
const val serialVersionUID = 2L
|
||||||
|
|
||||||
val children by lazy {
|
val children by lazy {
|
||||||
entries.filter { it.parent != null }.groupBy { it.parent }
|
entries.filter { it.parent != null }.groupBy { it.parent }
|
||||||
|
|||||||
+4
-1
@@ -112,6 +112,9 @@ enum class GradleBuildTime(private val parent: GradleBuildTime? = null, private
|
|||||||
COMPILER_INITIALIZATION(COMPILER_PERFORMANCE, "Compiler initialization time"),
|
COMPILER_INITIALIZATION(COMPILER_PERFORMANCE, "Compiler initialization time"),
|
||||||
CODE_ANALYSIS(COMPILER_PERFORMANCE, "Compiler code analysis"),
|
CODE_ANALYSIS(COMPILER_PERFORMANCE, "Compiler code analysis"),
|
||||||
CODE_GENERATION(COMPILER_PERFORMANCE, "Compiler code generation"),
|
CODE_GENERATION(COMPILER_PERFORMANCE, "Compiler code generation"),
|
||||||
|
IR_TRANSLATION(COMPILER_PERFORMANCE, "Compiler IR translation"),
|
||||||
|
IR_LOWERING(COMPILER_PERFORMANCE, "Compiler IR lowering"),
|
||||||
|
IR_GENERATION(COMPILER_PERFORMANCE, "Compiler IR generation"),
|
||||||
IC_WRITE_HISTORY_FILE(INCREMENTAL_COMPILATION_DAEMON, "Write history file"),
|
IC_WRITE_HISTORY_FILE(INCREMENTAL_COMPILATION_DAEMON, "Write history file"),
|
||||||
SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION(INCREMENTAL_COMPILATION_DAEMON, "Shrink and save current classpath snapshot after compilation"),
|
SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION(INCREMENTAL_COMPILATION_DAEMON, "Shrink and save current classpath snapshot after compilation"),
|
||||||
INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT(SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION, "Shrink current classpath snapshot incrementally"),
|
INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT(SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION, "Shrink current classpath snapshot incrementally"),
|
||||||
@@ -145,7 +148,7 @@ enum class GradleBuildTime(private val parent: GradleBuildTime? = null, private
|
|||||||
override fun getName(): String = this.name
|
override fun getName(): String = this.name
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val serialVersionUID = 1L
|
const val serialVersionUID = 2L
|
||||||
|
|
||||||
val children by lazy {
|
val children by lazy {
|
||||||
entries.filter { it.parent != null }.groupBy { it.parent }
|
entries.filter { it.parent != null }.groupBy { it.parent }
|
||||||
|
|||||||
+29
-11
@@ -53,7 +53,7 @@ import java.nio.file.Files
|
|||||||
|
|
||||||
abstract class IncrementalCompilerRunner<
|
abstract class IncrementalCompilerRunner<
|
||||||
Args : CommonCompilerArguments,
|
Args : CommonCompilerArguments,
|
||||||
CacheManager : IncrementalCachesManager<*>
|
CacheManager : IncrementalCachesManager<*>,
|
||||||
>(
|
>(
|
||||||
private val workingDir: File,
|
private val workingDir: File,
|
||||||
cacheDirName: String,
|
cacheDirName: String,
|
||||||
@@ -93,8 +93,8 @@ abstract class IncrementalCompilerRunner<
|
|||||||
transaction: CompilationTransaction,
|
transaction: CompilationTransaction,
|
||||||
fragmentContext: FragmentContext? = null,
|
fragmentContext: FragmentContext? = null,
|
||||||
) = IncrementalCompilationContext(
|
) = IncrementalCompilationContext(
|
||||||
pathConverterForSourceFiles = fileLocations?.let { it.getRelocatablePathConverterForSourceFiles() } ?: BasicFileToPathConverter,
|
pathConverterForSourceFiles = fileLocations?.getRelocatablePathConverterForSourceFiles() ?: BasicFileToPathConverter,
|
||||||
pathConverterForOutputFiles = fileLocations?.let { it.getRelocatablePathConverterForOutputFiles() } ?: BasicFileToPathConverter,
|
pathConverterForOutputFiles = fileLocations?.getRelocatablePathConverterForOutputFiles() ?: BasicFileToPathConverter,
|
||||||
transaction = transaction,
|
transaction = transaction,
|
||||||
reporter = reporter,
|
reporter = reporter,
|
||||||
trackChangesInLookupCache = shouldTrackChangesInLookupCache,
|
trackChangesInLookupCache = shouldTrackChangesInLookupCache,
|
||||||
@@ -328,7 +328,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
private fun getChangedFiles(
|
private fun getChangedFiles(
|
||||||
changedFiles: ChangedFiles.Known?,
|
changedFiles: ChangedFiles.Known?,
|
||||||
allSourceFiles: List<File>,
|
allSourceFiles: List<File>,
|
||||||
caches: CacheManager
|
caches: CacheManager,
|
||||||
): ChangedFiles.Known {
|
): ChangedFiles.Known {
|
||||||
return when {
|
return when {
|
||||||
changedFiles == null -> caches.inputsCache.sourceSnapshotMap.compareAndUpdate(allSourceFiles)
|
changedFiles == null -> caches.inputsCache.sourceSnapshotMap.compareAndUpdate(allSourceFiles)
|
||||||
@@ -348,10 +348,13 @@ abstract class IncrementalCompilerRunner<
|
|||||||
changedFiles: ChangedFiles.Known,
|
changedFiles: ChangedFiles.Known,
|
||||||
args: Args,
|
args: Args,
|
||||||
messageCollector: MessageCollector,
|
messageCollector: MessageCollector,
|
||||||
classpathAbiSnapshots: Map<String, AbiSnapshot>
|
classpathAbiSnapshots: Map<String, AbiSnapshot>,
|
||||||
): CompilationMode
|
): CompilationMode
|
||||||
|
|
||||||
protected open fun setupJarDependencies(args: Args, reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>): Map<String, AbiSnapshot> = emptyMap()
|
protected open fun setupJarDependencies(
|
||||||
|
args: Args,
|
||||||
|
reporter: BuildReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||||
|
): Map<String, AbiSnapshot> = emptyMap()
|
||||||
|
|
||||||
protected fun initDirtyFiles(dirtyFiles: DirtyFilesContainer, changedFiles: ChangedFiles.Known) {
|
protected fun initDirtyFiles(dirtyFiles: DirtyFilesContainer, changedFiles: ChangedFiles.Known) {
|
||||||
dirtyFiles.add(changedFiles.modified, "was modified since last time")
|
dirtyFiles.add(changedFiles.modified, "was modified since last time")
|
||||||
@@ -372,7 +375,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
services: Services,
|
services: Services,
|
||||||
caches: CacheManager,
|
caches: CacheManager,
|
||||||
generatedFiles: List<GeneratedFile>,
|
generatedFiles: List<GeneratedFile>,
|
||||||
changesCollector: ChangesCollector
|
changesCollector: ChangesCollector,
|
||||||
)
|
)
|
||||||
|
|
||||||
protected open fun additionalDirtyFiles(caches: CacheManager, generatedFiles: List<GeneratedFile>, services: Services): Iterable<File> =
|
protected open fun additionalDirtyFiles(caches: CacheManager, generatedFiles: List<GeneratedFile>, services: Services): Iterable<File> =
|
||||||
@@ -387,7 +390,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
expectActualTracker: ExpectActualTracker,
|
expectActualTracker: ExpectActualTracker,
|
||||||
caches: CacheManager,
|
caches: CacheManager,
|
||||||
dirtySources: Set<File>,
|
dirtySources: Set<File>,
|
||||||
isIncremental: Boolean
|
isIncremental: Boolean,
|
||||||
): Services.Builder =
|
): Services.Builder =
|
||||||
Services.Builder().apply {
|
Services.Builder().apply {
|
||||||
register(LookupTracker::class.java, lookupTracker)
|
register(LookupTracker::class.java, lookupTracker)
|
||||||
@@ -402,7 +405,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
services: Services,
|
services: Services,
|
||||||
messageCollector: MessageCollector,
|
messageCollector: MessageCollector,
|
||||||
allSources: List<File>,
|
allSources: List<File>,
|
||||||
isIncremental: Boolean
|
isIncremental: Boolean,
|
||||||
): Pair<ExitCode, Collection<File>>
|
): Pair<ExitCode, Collection<File>>
|
||||||
|
|
||||||
private fun compileImpl(
|
private fun compileImpl(
|
||||||
@@ -496,7 +499,8 @@ abstract class IncrementalCompilerRunner<
|
|||||||
val outputItemsCollector = OutputItemsCollectorImpl()
|
val outputItemsCollector = OutputItemsCollectorImpl()
|
||||||
val transactionOutputsRegistrar = TransactionOutputsRegistrar(transaction, outputItemsCollector)
|
val transactionOutputsRegistrar = TransactionOutputsRegistrar(transaction, outputItemsCollector)
|
||||||
val bufferingMessageCollector = BufferingMessageCollector()
|
val bufferingMessageCollector = BufferingMessageCollector()
|
||||||
val messageCollectorAdapter = MessageCollectorToOutputItemsCollectorAdapter(bufferingMessageCollector, transactionOutputsRegistrar)
|
val messageCollectorAdapter =
|
||||||
|
MessageCollectorToOutputItemsCollectorAdapter(bufferingMessageCollector, transactionOutputsRegistrar)
|
||||||
|
|
||||||
val compiledSources = reporter.measure(GradleBuildTime.COMPILATION_ROUND) {
|
val compiledSources = reporter.measure(GradleBuildTime.COMPILATION_ROUND) {
|
||||||
runCompiler(
|
runCompiler(
|
||||||
@@ -607,7 +611,7 @@ abstract class IncrementalCompilerRunner<
|
|||||||
|
|
||||||
protected fun getRemovedClassesChanges(
|
protected fun getRemovedClassesChanges(
|
||||||
caches: IncrementalCachesManager<*>,
|
caches: IncrementalCachesManager<*>,
|
||||||
changedFiles: ChangedFiles.Known
|
changedFiles: ChangedFiles.Known,
|
||||||
): DirtyData {
|
): DirtyData {
|
||||||
val removedClasses = HashSet<String>()
|
val removedClasses = HashSet<String>()
|
||||||
val dirtyFiles = changedFiles.modified.filterTo(HashSet()) { it.isKotlinFile(kotlinSourceFilesExtensions) }
|
val dirtyFiles = changedFiles.modified.filterTo(HashSet()) { it.isKotlinFile(kotlinSourceFilesExtensions) }
|
||||||
@@ -684,9 +688,23 @@ abstract class IncrementalCompilerRunner<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is IRMeasurement -> {
|
||||||
|
when (it.kind) {
|
||||||
|
IRMeasurement.Kind.TRANSLATION -> reportIrMeasurements(it, GradleBuildTime.IR_TRANSLATION, GradleBuildPerformanceMetric.IR_TRANSLATION_LINES_NUMBER)
|
||||||
|
IRMeasurement.Kind.LOWERING -> reportIrMeasurements(it, GradleBuildTime.IR_LOWERING, GradleBuildPerformanceMetric.IR_LOWERING_LINES_NUMBER)
|
||||||
|
IRMeasurement.Kind.GENERATION -> reportIrMeasurements(it, GradleBuildTime.IR_GENERATION, GradleBuildPerformanceMetric.IR_GENERATION_LINES_NUMBER)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun reportIrMeasurements(it: IRMeasurement, timeMetric: GradleBuildTime, lineMetric: GradleBuildPerformanceMetric) {
|
||||||
|
reporter.addTimeMetricMs(timeMetric, it.milliseconds)
|
||||||
|
it.lines?.also {
|
||||||
|
reporter.addMetric(lineMetric, it.toLong())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Temporary function to reuse the logic. KT-62759")
|
@Deprecated("Temporary function to reuse the logic. KT-62759")
|
||||||
|
|||||||
+6
@@ -195,6 +195,12 @@ class BuildReportsIT : KGPBaseTest() {
|
|||||||
"Compiler code analysis:",
|
"Compiler code analysis:",
|
||||||
"Compiler code generation:",
|
"Compiler code generation:",
|
||||||
"Compiler initialization time:",
|
"Compiler initialization time:",
|
||||||
|
"Compiler IR translation line number:",
|
||||||
|
"Compiler IR lowering line number:",
|
||||||
|
"Compiler IR generation line number:",
|
||||||
|
"Compiler IR translation:",
|
||||||
|
"Compiler IR lowering:",
|
||||||
|
"Compiler IR generation:",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user