KT-54959 Add worker execution time to task action execution time
This commit is contained in:
@@ -12,6 +12,7 @@ interface BuildMetricsReporter {
|
|||||||
fun addTimeMetricMs(time: BuildTime, durationMs: Long) = addTimeMetricNs(time, durationMs * 1_000_000)
|
fun addTimeMetricMs(time: BuildTime, durationMs: Long) = addTimeMetricNs(time, durationMs * 1_000_000)
|
||||||
|
|
||||||
fun addMetric(metric: BuildPerformanceMetric, value: Long)
|
fun addMetric(metric: BuildPerformanceMetric, value: Long)
|
||||||
|
fun addTimeMetric(metric: BuildPerformanceMetric)
|
||||||
|
|
||||||
fun addAttribute(attribute: BuildAttribute)
|
fun addAttribute(attribute: BuildAttribute)
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,15 @@ class BuildMetricsReporterImpl : BuildMetricsReporter, Serializable {
|
|||||||
myBuildMetrics.add(metric, value)
|
myBuildMetrics.add(metric, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun addTimeMetric(metric: BuildPerformanceMetric) {
|
||||||
|
when (metric.type) {
|
||||||
|
ValueType.NANOSECONDS -> myBuildMetrics.add(metric, System.nanoTime())
|
||||||
|
ValueType.MILLISECONDS -> myBuildMetrics.add(metric, System.currentTimeMillis())
|
||||||
|
else -> error("Unable to add time metric for '${metric.type}' type")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
override fun addAttribute(attribute: BuildAttribute) {
|
override fun addAttribute(attribute: BuildAttribute) {
|
||||||
myBuildAttributes.add(attribute)
|
myBuildAttributes.add(attribute)
|
||||||
}
|
}
|
||||||
|
|||||||
+30
-21
@@ -8,30 +8,37 @@ package org.jetbrains.kotlin.build.report.metrics
|
|||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
@Suppress("Reformat")
|
@Suppress("Reformat")
|
||||||
enum class BuildPerformanceMetric(val parent: BuildPerformanceMetric? = null, val readableString: String, val type: SizeMetricType) : Serializable {
|
enum class BuildPerformanceMetric(val parent: BuildPerformanceMetric? = null, val readableString: String, val type: ValueType) : Serializable {
|
||||||
CACHE_DIRECTORY_SIZE(readableString = "Total size of the cache directory", type = SizeMetricType.BYTES),
|
CACHE_DIRECTORY_SIZE(readableString = "Total size of the cache directory", type = ValueType.BYTES),
|
||||||
LOOKUP_SIZE(CACHE_DIRECTORY_SIZE, "Lookups size", type = SizeMetricType.BYTES),
|
LOOKUP_SIZE(CACHE_DIRECTORY_SIZE, "Lookups size", type = ValueType.BYTES),
|
||||||
SNAPSHOT_SIZE(CACHE_DIRECTORY_SIZE, "ABI snapshot size", type = SizeMetricType.BYTES),
|
SNAPSHOT_SIZE(CACHE_DIRECTORY_SIZE, "ABI snapshot size", type = ValueType.BYTES),
|
||||||
|
|
||||||
BUNDLE_SIZE(readableString = "Total size of the final bundle", type = SizeMetricType.BYTES),
|
BUNDLE_SIZE(readableString = "Total size of the final bundle", type = ValueType.BYTES),
|
||||||
|
|
||||||
COMPILE_ITERATION(parent = null, "Total compiler iteration", type = SizeMetricType.NUMBER),
|
COMPILE_ITERATION(parent = null, "Total compiler iteration", type = ValueType.NUMBER),
|
||||||
|
|
||||||
// Metrics for the `kotlin.incremental.useClasspathSnapshot` feature
|
// Metrics for the `kotlin.incremental.useClasspathSnapshot` feature
|
||||||
CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT(parent = null, "Number of times 'ClasspathEntrySnapshotTransform' ran", type = SizeMetricType.NUMBER),
|
CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT(parent = null, "Number of times 'ClasspathEntrySnapshotTransform' ran", type = ValueType.NUMBER),
|
||||||
JAR_CLASSPATH_ENTRY_SIZE(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT, "Size of jar classpath entry", type = SizeMetricType.BYTES),
|
JAR_CLASSPATH_ENTRY_SIZE(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT, "Size of jar classpath entry", type = ValueType.BYTES),
|
||||||
JAR_CLASSPATH_ENTRY_SNAPSHOT_SIZE(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT, "Size of jar classpath entry's snapshot", type = SizeMetricType.BYTES),
|
JAR_CLASSPATH_ENTRY_SNAPSHOT_SIZE(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT, "Size of jar classpath entry's snapshot", type = ValueType.BYTES),
|
||||||
DIRECTORY_CLASSPATH_ENTRY_SNAPSHOT_SIZE(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT, "Size of directory classpath entry's snapshot", type = SizeMetricType.BYTES),
|
DIRECTORY_CLASSPATH_ENTRY_SNAPSHOT_SIZE(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM_EXECUTION_COUNT, "Size of directory classpath entry's snapshot", type = ValueType.BYTES),
|
||||||
COMPUTE_CLASSPATH_CHANGES_EXECUTION_COUNT(parent = null, "Number of times classpath changes are computed", type = SizeMetricType.NUMBER),
|
COMPUTE_CLASSPATH_CHANGES_EXECUTION_COUNT(parent = null, "Number of times classpath changes are computed", type = ValueType.NUMBER),
|
||||||
SHRINK_AND_SAVE_CLASSPATH_SNAPSHOT_EXECUTION_COUNT(parent = null, "Number of times classpath snapshot is shrunk and saved after compilation", type = SizeMetricType.NUMBER),
|
SHRINK_AND_SAVE_CLASSPATH_SNAPSHOT_EXECUTION_COUNT(parent = null, "Number of times classpath snapshot is shrunk and saved after compilation", type = ValueType.NUMBER),
|
||||||
CLASSPATH_ENTRY_COUNT(parent = SHRINK_AND_SAVE_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Number of classpath entries", type = SizeMetricType.NUMBER),
|
CLASSPATH_ENTRY_COUNT(parent = SHRINK_AND_SAVE_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Number of classpath entries", type = ValueType.NUMBER),
|
||||||
CLASSPATH_SNAPSHOT_SIZE(parent = SHRINK_AND_SAVE_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Size of classpath snapshot", type = SizeMetricType.BYTES),
|
CLASSPATH_SNAPSHOT_SIZE(parent = SHRINK_AND_SAVE_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Size of classpath snapshot", type = ValueType.BYTES),
|
||||||
SHRUNK_CLASSPATH_SNAPSHOT_SIZE(parent = SHRINK_AND_SAVE_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Size of shrunk classpath snapshot", type = SizeMetricType.BYTES),
|
SHRUNK_CLASSPATH_SNAPSHOT_SIZE(parent = SHRINK_AND_SAVE_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Size of shrunk classpath snapshot", type = ValueType.BYTES),
|
||||||
LOAD_CLASSPATH_SNAPSHOT_EXECUTION_COUNT(parent = null, "Number of times classpath snapshot is loaded", type = SizeMetricType.NUMBER),
|
LOAD_CLASSPATH_SNAPSHOT_EXECUTION_COUNT(parent = null, "Number of times classpath snapshot is loaded", type = ValueType.NUMBER),
|
||||||
LOAD_CLASSPATH_ENTRY_SNAPSHOT_CACHE_HITS(parent = LOAD_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Number of cache hits when loading classpath entry snapshots", type = SizeMetricType.NUMBER),
|
LOAD_CLASSPATH_ENTRY_SNAPSHOT_CACHE_HITS(parent = LOAD_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Number of cache hits when loading classpath entry snapshots", type = ValueType.NUMBER),
|
||||||
LOAD_CLASSPATH_ENTRY_SNAPSHOT_CACHE_MISSES(parent = LOAD_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Number of cache misses when loading classpath entry snapshots", type = SizeMetricType.NUMBER),
|
LOAD_CLASSPATH_ENTRY_SNAPSHOT_CACHE_MISSES(parent = LOAD_CLASSPATH_SNAPSHOT_EXECUTION_COUNT, "Number of cache misses when loading classpath entry snapshots", type = ValueType.NUMBER),
|
||||||
;
|
|
||||||
|
|
||||||
|
//exact time
|
||||||
|
START_TASK_ACTION_EXECUTION(readableString = "Start time of task action", type = ValueType.MILLISECONDS),
|
||||||
|
CALL_KOTLIN_DAEMON(readableString = "Finish gradle part of task execution", type = ValueType.NANOSECONDS),
|
||||||
|
CALL_WORKER(readableString = "Worker submit time", type = ValueType.NANOSECONDS),
|
||||||
|
START_WORKER_EXECUTION(readableString = "Start time of werker execution", type = ValueType.NANOSECONDS),
|
||||||
|
START_KOTLIN_DAEMON_EXECUTION(readableString = "Start time of kotlin daemon task execution", type = ValueType.NANOSECONDS),
|
||||||
|
FINISH_KOTLIN_DAEMON_EXECUTION(readableString = "Finish kotlin daemon execution", type = ValueType.MILLISECONDS),
|
||||||
|
;
|
||||||
companion object {
|
companion object {
|
||||||
const val serialVersionUID = 0L
|
const val serialVersionUID = 0L
|
||||||
|
|
||||||
@@ -41,7 +48,9 @@ enum class BuildPerformanceMetric(val parent: BuildPerformanceMetric? = null, va
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class SizeMetricType {
|
enum class ValueType {
|
||||||
BYTES,
|
BYTES,
|
||||||
NUMBER
|
NUMBER,
|
||||||
|
NANOSECONDS,
|
||||||
|
MILLISECONDS,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,58 +10,63 @@ import java.io.Serializable
|
|||||||
@Suppress("Reformat")
|
@Suppress("Reformat")
|
||||||
enum class BuildTime(val parent: BuildTime? = null, val readableString: String) : Serializable {
|
enum class BuildTime(val parent: BuildTime? = null, val readableString: String) : Serializable {
|
||||||
GRADLE_TASK(readableString = "Total Gradle task time"),
|
GRADLE_TASK(readableString = "Total Gradle task time"),
|
||||||
|
GRADLE_TASK_PREPARATION(readableString = "Spent time before task action"),
|
||||||
GRADLE_TASK_ACTION(readableString = "Task action"),
|
GRADLE_TASK_ACTION(readableString = "Task action"),
|
||||||
CLEAR_OUTPUT(GRADLE_TASK_ACTION, "Clear output"),
|
OUT_OF_WORKER_TASK_ACTION(GRADLE_TASK_ACTION, "Task action before worker execution"),
|
||||||
BACKUP_OUTPUT(GRADLE_TASK_ACTION, "Backup output"),
|
BACKUP_OUTPUT(OUT_OF_WORKER_TASK_ACTION, "Backup output"),
|
||||||
RESTORE_OUTPUT_FROM_BACKUP(GRADLE_TASK_ACTION, "Restore output"),
|
RUN_WORKER_DELAY(readableString = "Start gradle worker"),
|
||||||
CONNECT_TO_DAEMON(GRADLE_TASK_ACTION, "Connect to Kotlin daemon"),
|
RUN_COMPILATION_IN_WORKER(GRADLE_TASK_ACTION, "Run compilation in Gradle worker"),
|
||||||
CLEAR_JAR_CACHE(GRADLE_TASK_ACTION, "Clear jar cache"),
|
CLEAR_JAR_CACHE(RUN_COMPILATION_IN_WORKER, "Clear jar cache"),
|
||||||
CALCULATE_OUTPUT_SIZE(GRADLE_TASK_ACTION, "Calculate output size"),
|
CLEAR_OUTPUT(RUN_COMPILATION_IN_WORKER, "Clear output"),
|
||||||
RUN_COMPILATION(GRADLE_TASK_ACTION, "Run compilation"),
|
RESTORE_OUTPUT_FROM_BACKUP(RUN_COMPILATION_IN_WORKER, "Restore output"),
|
||||||
NON_INCREMENTAL_COMPILATION_IN_PROCESS(RUN_COMPILATION, "Non incremental inprocess compilation"),
|
CONNECT_TO_DAEMON(RUN_COMPILATION_IN_WORKER, "Connect to Kotlin daemon"),
|
||||||
NON_INCREMENTAL_COMPILATION_OUT_OF_PROCESS(RUN_COMPILATION, "Non incremental out of process compilation"),
|
CALCULATE_OUTPUT_SIZE(RUN_COMPILATION_IN_WORKER, "Calculate output size"),
|
||||||
NON_INCREMENTAL_COMPILATION_DAEMON(RUN_COMPILATION, "Non incremental compilation in daemon"),
|
RUN_COMPILATION(RUN_COMPILATION_IN_WORKER, "Run compilation"),
|
||||||
INCREMENTAL_COMPILATION_DAEMON(RUN_COMPILATION, "Incremental compilation in daemon"),
|
NON_INCREMENTAL_COMPILATION_IN_PROCESS(RUN_COMPILATION, "Non incremental inprocess compilation"),
|
||||||
STORE_BUILD_INFO(INCREMENTAL_COMPILATION_DAEMON, "Store build info"),
|
NON_INCREMENTAL_COMPILATION_OUT_OF_PROCESS(RUN_COMPILATION, "Non incremental out of process compilation"),
|
||||||
JAR_SNAPSHOT(INCREMENTAL_COMPILATION_DAEMON, "ABI JAR Snapshot support"),
|
NON_INCREMENTAL_COMPILATION_DAEMON(RUN_COMPILATION, "Non incremental compilation in daemon"),
|
||||||
SET_UP_ABI_SNAPSHOTS(JAR_SNAPSHOT, "Set up ABI snapshot"),
|
INCREMENTAL_COMPILATION_DAEMON(RUN_COMPILATION, "Incremental compilation in daemon"),
|
||||||
IC_ANALYZE_JAR_FILES(JAR_SNAPSHOT, "Analyze jar files"),
|
STORE_BUILD_INFO(INCREMENTAL_COMPILATION_DAEMON, "Store build info"),
|
||||||
IC_CALCULATE_INITIAL_DIRTY_SET(INCREMENTAL_COMPILATION_DAEMON, "Calculate initial dirty sources set"), //TODO
|
JAR_SNAPSHOT(INCREMENTAL_COMPILATION_DAEMON, "ABI JAR Snapshot support"),
|
||||||
COMPUTE_CLASSPATH_CHANGES(IC_CALCULATE_INITIAL_DIRTY_SET, "Compute classpath changes"),
|
SET_UP_ABI_SNAPSHOTS(JAR_SNAPSHOT, "Set up ABI snapshot"),
|
||||||
LOAD_CURRENT_CLASSPATH_SNAPSHOT(COMPUTE_CLASSPATH_CHANGES, "Load current classpath snapshot"),
|
IC_ANALYZE_JAR_FILES(JAR_SNAPSHOT, "Analyze jar files"),
|
||||||
REMOVE_DUPLICATE_CLASSES(LOAD_CURRENT_CLASSPATH_SNAPSHOT, "Remove duplicate classes"),
|
IC_CALCULATE_INITIAL_DIRTY_SET(INCREMENTAL_COMPILATION_DAEMON, "Calculate initial dirty sources set"), //TODO
|
||||||
SHRINK_CURRENT_CLASSPATH_SNAPSHOT(COMPUTE_CLASSPATH_CHANGES, "Shrink current classpath snapshot"),
|
COMPUTE_CLASSPATH_CHANGES(IC_CALCULATE_INITIAL_DIRTY_SET, "Compute classpath changes"),
|
||||||
GET_LOOKUP_SYMBOLS(SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Get lookup symbols"),
|
LOAD_CURRENT_CLASSPATH_SNAPSHOT(COMPUTE_CLASSPATH_CHANGES, "Load current classpath snapshot"),
|
||||||
FIND_REFERENCED_CLASSES(SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Find referenced classes"),
|
REMOVE_DUPLICATE_CLASSES(LOAD_CURRENT_CLASSPATH_SNAPSHOT, "Remove duplicate classes"),
|
||||||
FIND_TRANSITIVELY_REFERENCED_CLASSES(SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Find transitively referenced classes"),
|
SHRINK_CURRENT_CLASSPATH_SNAPSHOT(COMPUTE_CLASSPATH_CHANGES, "Shrink current classpath snapshot"),
|
||||||
LOAD_SHRUNK_PREVIOUS_CLASSPATH_SNAPSHOT(COMPUTE_CLASSPATH_CHANGES, "Load shrunk previous classpath snapshot"),
|
GET_LOOKUP_SYMBOLS(SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Get lookup symbols"),
|
||||||
COMPUTE_CHANGED_AND_IMPACTED_SET(COMPUTE_CLASSPATH_CHANGES, "Compute changed and impacted set"),
|
FIND_REFERENCED_CLASSES(SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Find referenced classes"),
|
||||||
COMPUTE_CLASS_CHANGES(COMPUTE_CHANGED_AND_IMPACTED_SET, "Compute class changes"),
|
FIND_TRANSITIVELY_REFERENCED_CLASSES(SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Find transitively referenced classes"),
|
||||||
COMPUTE_KOTLIN_CLASS_CHANGES(COMPUTE_CLASS_CHANGES, "Compute Kotlin class changes"),
|
LOAD_SHRUNK_PREVIOUS_CLASSPATH_SNAPSHOT(COMPUTE_CLASSPATH_CHANGES, "Load shrunk previous classpath snapshot"),
|
||||||
COMPUTE_JAVA_CLASS_CHANGES(COMPUTE_CLASS_CHANGES, "Compute Java class changes"),
|
COMPUTE_CHANGED_AND_IMPACTED_SET(COMPUTE_CLASSPATH_CHANGES, "Compute changed and impacted set"),
|
||||||
COMPUTE_IMPACTED_SET(COMPUTE_CHANGED_AND_IMPACTED_SET, "Compute impacted set"),
|
COMPUTE_CLASS_CHANGES(COMPUTE_CHANGED_AND_IMPACTED_SET, "Compute class changes"),
|
||||||
IC_ANALYZE_CHANGES_IN_DEPENDENCIES(IC_CALCULATE_INITIAL_DIRTY_SET, "Analyze dependency changes"),
|
COMPUTE_KOTLIN_CLASS_CHANGES(COMPUTE_CLASS_CHANGES, "Compute Kotlin class changes"),
|
||||||
IC_FIND_HISTORY_FILES(IC_ANALYZE_CHANGES_IN_DEPENDENCIES, "Find history files"),
|
COMPUTE_JAVA_CLASS_CHANGES(COMPUTE_CLASS_CHANGES, "Compute Java class changes"),
|
||||||
IC_ANALYZE_HISTORY_FILES(IC_ANALYZE_CHANGES_IN_DEPENDENCIES, "Analyze history files"),
|
COMPUTE_IMPACTED_SET(COMPUTE_CHANGED_AND_IMPACTED_SET, "Compute impacted set"),
|
||||||
IC_ANALYZE_CHANGES_IN_JAVA_SOURCES(IC_CALCULATE_INITIAL_DIRTY_SET, "Analyze Java file changes"),
|
IC_ANALYZE_CHANGES_IN_DEPENDENCIES(IC_CALCULATE_INITIAL_DIRTY_SET, "Analyze dependency changes"),
|
||||||
IC_ANALYZE_CHANGES_IN_ANDROID_LAYOUTS(IC_CALCULATE_INITIAL_DIRTY_SET, "Analyze Android layouts"),
|
IC_FIND_HISTORY_FILES(IC_ANALYZE_CHANGES_IN_DEPENDENCIES, "Find history files"),
|
||||||
IC_DETECT_REMOVED_CLASSES(IC_CALCULATE_INITIAL_DIRTY_SET, "Detect removed classes"),
|
IC_ANALYZE_HISTORY_FILES(IC_ANALYZE_CHANGES_IN_DEPENDENCIES, "Analyze history files"),
|
||||||
CLEAR_OUTPUT_ON_REBUILD(INCREMENTAL_COMPILATION_DAEMON, "Clear outputs on rebuild"),
|
IC_ANALYZE_CHANGES_IN_JAVA_SOURCES(IC_CALCULATE_INITIAL_DIRTY_SET, "Analyze Java file changes"),
|
||||||
IC_UPDATE_CACHES(INCREMENTAL_COMPILATION_DAEMON, "Update caches"),
|
IC_ANALYZE_CHANGES_IN_ANDROID_LAYOUTS(IC_CALCULATE_INITIAL_DIRTY_SET, "Analyze Android layouts"),
|
||||||
COMPILATION_ROUND(INCREMENTAL_COMPILATION_DAEMON, "Sources compilation round"),
|
IC_DETECT_REMOVED_CLASSES(IC_CALCULATE_INITIAL_DIRTY_SET, "Detect removed classes"),
|
||||||
IC_WRITE_HISTORY_FILE(INCREMENTAL_COMPILATION_DAEMON, "Write history file"),
|
CLEAR_OUTPUT_ON_REBUILD(INCREMENTAL_COMPILATION_DAEMON, "Clear outputs on rebuild"),
|
||||||
SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION(INCREMENTAL_COMPILATION_DAEMON, "Shrink and save current classpath snapshot after compilation"),
|
IC_UPDATE_CACHES(INCREMENTAL_COMPILATION_DAEMON, "Update caches"),
|
||||||
INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT(SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION, "Shrink current classpath snapshot incrementally"),
|
COMPILATION_ROUND(INCREMENTAL_COMPILATION_DAEMON, "Sources compilation round"),
|
||||||
INCREMENTAL_LOAD_CURRENT_CLASSPATH_SNAPSHOT(INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Load current classpath snapshot"),
|
COMPILER_PERFORMANCE(COMPILATION_ROUND, readableString = "Compiler time"),
|
||||||
INCREMENTAL_LOAD_SHRUNK_CURRENT_CLASSPATH_SNAPSHOT_AGAINST_PREVIOUS_LOOKUPS(INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Load shrunk current classpath snapshot against previous lookups"),
|
COMPILER_INITIALIZATION(COMPILER_PERFORMANCE, "Compiler initialization time"),
|
||||||
NON_INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT(SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION, "Shrink current classpath snapshot non-incrementally"),
|
CODE_ANALYSIS(COMPILER_PERFORMANCE, "Compiler code analysis"),
|
||||||
NON_INCREMENTAL_LOAD_CURRENT_CLASSPATH_SNAPSHOT(NON_INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Load current classpath snapshot"),
|
CODE_GENERATION(COMPILER_PERFORMANCE, "Compiler code generation"),
|
||||||
SAVE_SHRUNK_CURRENT_CLASSPATH_SNAPSHOT(SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION, "Save shrunk current classpath snapshot"),
|
IC_WRITE_HISTORY_FILE(INCREMENTAL_COMPILATION_DAEMON, "Write history file"),
|
||||||
COMPILER_PERFORMANCE(readableString = "Compiler time"),
|
SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION(INCREMENTAL_COMPILATION_DAEMON, "Shrink and save current classpath snapshot after compilation"),
|
||||||
COMPILER_INITIALIZATION(COMPILER_PERFORMANCE, "Compiler initialization time"),
|
INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT(SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION, "Shrink current classpath snapshot incrementally"),
|
||||||
CODE_ANALYSIS(COMPILER_PERFORMANCE, "Compiler code analysis"),
|
INCREMENTAL_LOAD_CURRENT_CLASSPATH_SNAPSHOT(INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Load current classpath snapshot"),
|
||||||
CODE_GENERATION(COMPILER_PERFORMANCE, "Compiler code generation"),
|
INCREMENTAL_LOAD_SHRUNK_CURRENT_CLASSPATH_SNAPSHOT_AGAINST_PREVIOUS_LOOKUPS(INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Load shrunk current classpath snapshot against previous lookups"),
|
||||||
CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM(parent = null, "Classpath entry snapshot transform"),
|
NON_INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT(SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION, "Shrink current classpath snapshot non-incrementally"),
|
||||||
|
NON_INCREMENTAL_LOAD_CURRENT_CLASSPATH_SNAPSHOT(NON_INCREMENTAL_SHRINK_CURRENT_CLASSPATH_SNAPSHOT, "Load current classpath snapshot"),
|
||||||
|
SAVE_SHRUNK_CURRENT_CLASSPATH_SNAPSHOT(SHRINK_AND_SAVE_CURRENT_CLASSPATH_SNAPSHOT_AFTER_COMPILATION, "Save shrunk current classpath snapshot"),
|
||||||
|
TASK_FINISH_LISTENER_NOTIFICATION(readableString = "Task finish event notification"),
|
||||||
|
CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM(readableString = "Classpath entry snapshot transform"),
|
||||||
LOAD_CLASSES(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM, "Load classes"),
|
LOAD_CLASSES(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM, "Load classes"),
|
||||||
SNAPSHOT_CLASSES(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM, "Snapshot classes"),
|
SNAPSHOT_CLASSES(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM, "Snapshot classes"),
|
||||||
READ_CLASSES_BASIC_INFO(parent = SNAPSHOT_CLASSES, "Read basic information about classes"),
|
READ_CLASSES_BASIC_INFO(parent = SNAPSHOT_CLASSES, "Read basic information about classes"),
|
||||||
@@ -69,6 +74,7 @@ enum class BuildTime(val parent: BuildTime? = null, val readableString: String)
|
|||||||
SNAPSHOT_KOTLIN_CLASSES(parent = SNAPSHOT_CLASSES, "Snapshot Kotlin classes"),
|
SNAPSHOT_KOTLIN_CLASSES(parent = SNAPSHOT_CLASSES, "Snapshot Kotlin classes"),
|
||||||
SNAPSHOT_JAVA_CLASSES(parent = SNAPSHOT_CLASSES, "Snapshot Java classes"),
|
SNAPSHOT_JAVA_CLASSES(parent = SNAPSHOT_CLASSES, "Snapshot Java classes"),
|
||||||
SAVE_CLASSPATH_ENTRY_SNAPSHOT(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM, "Save classpath entry snapshot"),
|
SAVE_CLASSPATH_ENTRY_SNAPSHOT(parent = CLASSPATH_ENTRY_SNAPSHOT_TRANSFORM, "Save classpath entry snapshot"),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ class BuildTimes : Serializable {
|
|||||||
|
|
||||||
fun addTimeMs(buildTime: BuildTime, timeMs: Long) = addTimeNs(buildTime, timeMs * 1_000_000)
|
fun addTimeMs(buildTime: BuildTime, timeMs: Long) = addTimeNs(buildTime, timeMs * 1_000_000)
|
||||||
|
|
||||||
fun asMapNs(): Map<BuildTime, Long> = buildTimesNs
|
|
||||||
|
|
||||||
fun asMapMs(): Map<BuildTime, Long> = buildTimesNs.mapValues { it.value / 1_000_000 }
|
fun asMapMs(): Map<BuildTime, Long> = buildTimesNs.mapValues { it.value / 1_000_000 }
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+3
@@ -18,6 +18,9 @@ object DoNothingBuildMetricsReporter : BuildMetricsReporter {
|
|||||||
override fun addMetric(metric: BuildPerformanceMetric, value: Long) {
|
override fun addMetric(metric: BuildPerformanceMetric, value: Long) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun addTimeMetric(metric: BuildPerformanceMetric) {
|
||||||
|
}
|
||||||
|
|
||||||
override fun addAttribute(attribute: BuildAttribute) {
|
override fun addAttribute(attribute: BuildAttribute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
@@ -15,6 +15,7 @@ import org.gradle.workers.WorkParameters
|
|||||||
import org.gradle.workers.WorkQueue
|
import org.gradle.workers.WorkQueue
|
||||||
import org.gradle.workers.WorkerExecutor
|
import org.gradle.workers.WorkerExecutor
|
||||||
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
|
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
|
||||||
|
import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric
|
||||||
import org.jetbrains.kotlin.build.report.metrics.BuildTime
|
import org.jetbrains.kotlin.build.report.metrics.BuildTime
|
||||||
import org.jetbrains.kotlin.build.report.metrics.measure
|
import org.jetbrains.kotlin.build.report.metrics.measure
|
||||||
import org.jetbrains.kotlin.gradle.tasks.*
|
import org.jetbrains.kotlin.gradle.tasks.*
|
||||||
@@ -36,6 +37,7 @@ internal class GradleCompilerRunnerWithWorkers(
|
|||||||
taskOutputsBackup: TaskOutputsBackup?
|
taskOutputsBackup: TaskOutputsBackup?
|
||||||
): WorkQueue {
|
): WorkQueue {
|
||||||
|
|
||||||
|
buildMetrics.addTimeMetric(BuildPerformanceMetric.CALL_WORKER)
|
||||||
val workQueue = workerExecutor.noIsolation()
|
val workQueue = workerExecutor.noIsolation()
|
||||||
workQueue.submit(GradleKotlinCompilerWorkAction::class.java) { params ->
|
workQueue.submit(GradleKotlinCompilerWorkAction::class.java) { params ->
|
||||||
params.compilerWorkArguments.set(workArgs)
|
params.compilerWorkArguments.set(workArgs)
|
||||||
|
|||||||
+2
@@ -12,6 +12,7 @@ import org.gradle.api.tasks.bundling.AbstractArchiveTask
|
|||||||
import org.gradle.jvm.tasks.Jar
|
import org.gradle.jvm.tasks.Jar
|
||||||
import org.gradle.workers.WorkQueue
|
import org.gradle.workers.WorkQueue
|
||||||
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
|
import org.jetbrains.kotlin.build.report.metrics.BuildMetricsReporter
|
||||||
|
import org.jetbrains.kotlin.build.report.metrics.BuildPerformanceMetric
|
||||||
import org.jetbrains.kotlin.build.report.metrics.BuildTime
|
import org.jetbrains.kotlin.build.report.metrics.BuildTime
|
||||||
import org.jetbrains.kotlin.build.report.metrics.measure
|
import org.jetbrains.kotlin.build.report.metrics.measure
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.*
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
@@ -220,6 +221,7 @@ internal open class GradleCompilerRunner(
|
|||||||
taskOutputsBackup: TaskOutputsBackup?
|
taskOutputsBackup: TaskOutputsBackup?
|
||||||
): WorkQueue? {
|
): WorkQueue? {
|
||||||
try {
|
try {
|
||||||
|
buildMetrics.addTimeMetric(BuildPerformanceMetric.CALL_WORKER)
|
||||||
val kotlinCompilerRunnable = GradleKotlinCompilerWork(workArgs)
|
val kotlinCompilerRunnable = GradleKotlinCompilerWork(workArgs)
|
||||||
kotlinCompilerRunnable.run()
|
kotlinCompilerRunnable.run()
|
||||||
} catch (e: FailedCompilationException) {
|
} catch (e: FailedCompilationException) {
|
||||||
|
|||||||
+4
@@ -124,6 +124,8 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
get() = incrementalCompilationEnvironment != null
|
get() = incrementalCompilationEnvironment != null
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
|
metrics.addTimeMetric(BuildPerformanceMetric.START_WORKER_EXECUTION)
|
||||||
|
metrics.startMeasure(BuildTime.RUN_COMPILATION_IN_WORKER)
|
||||||
try {
|
try {
|
||||||
val gradlePrintingMessageCollector = GradlePrintingMessageCollector(log, allWarningsAsErrors)
|
val gradlePrintingMessageCollector = GradlePrintingMessageCollector(log, allWarningsAsErrors)
|
||||||
val gradleMessageCollector = GradleErrorMessageCollector(gradlePrintingMessageCollector, kotlinPluginVersion = kotlinPluginVersion)
|
val gradleMessageCollector = GradleErrorMessageCollector(gradlePrintingMessageCollector, kotlinPluginVersion = kotlinPluginVersion)
|
||||||
@@ -141,6 +143,7 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
withAbiSnapshot = incrementalCompilationEnvironment?.withAbiSnapshot,
|
withAbiSnapshot = incrementalCompilationEnvironment?.withAbiSnapshot,
|
||||||
withArtifactTransform = incrementalCompilationEnvironment?.classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled
|
withArtifactTransform = incrementalCompilationEnvironment?.classpathChanges is ClasspathChanges.ClasspathSnapshotEnabled
|
||||||
)
|
)
|
||||||
|
metrics.endMeasure(BuildTime.RUN_COMPILATION_IN_WORKER)
|
||||||
val result = TaskExecutionResult(buildMetrics = metrics.getMetrics(), icLogLines = icLogLines, taskInfo = taskInfo)
|
val result = TaskExecutionResult(buildMetrics = metrics.getMetrics(), icLogLines = icLogLines, taskInfo = taskInfo)
|
||||||
TaskExecutionResults[taskPath] = result
|
TaskExecutionResults[taskPath] = result
|
||||||
}
|
}
|
||||||
@@ -297,6 +300,7 @@ internal class GradleKotlinCompilerWork @Inject constructor(
|
|||||||
log.info("Options for KOTLIN DAEMON: $compilationOptions")
|
log.info("Options for KOTLIN DAEMON: $compilationOptions")
|
||||||
val servicesFacade = GradleIncrementalCompilerServicesFacadeImpl(log, bufferingMessageCollector)
|
val servicesFacade = GradleIncrementalCompilerServicesFacadeImpl(log, bufferingMessageCollector)
|
||||||
val compilationResults = GradleCompilationResults(log, projectRootFile)
|
val compilationResults = GradleCompilationResults(log, projectRootFile)
|
||||||
|
metrics.addTimeMetric(BuildPerformanceMetric.CALL_KOTLIN_DAEMON)
|
||||||
return metrics.measure(BuildTime.RUN_COMPILATION) {
|
return metrics.measure(BuildTime.RUN_COMPILATION) {
|
||||||
daemon.compile(sessionId, compilerArgs, compilationOptions, servicesFacade, compilationResults)
|
daemon.compile(sessionId, compilerArgs, compilationOptions, servicesFacade, compilationResults)
|
||||||
}.also {
|
}.also {
|
||||||
|
|||||||
+7
-5
@@ -17,7 +17,7 @@ import org.gradle.api.services.BuildServiceParameters
|
|||||||
import org.gradle.tooling.events.FinishEvent
|
import org.gradle.tooling.events.FinishEvent
|
||||||
import org.gradle.tooling.events.OperationCompletionListener
|
import org.gradle.tooling.events.OperationCompletionListener
|
||||||
import org.gradle.tooling.events.task.TaskFinishEvent
|
import org.gradle.tooling.events.task.TaskFinishEvent
|
||||||
import org.jetbrains.kotlin.build.report.metrics.SizeMetricType
|
import org.jetbrains.kotlin.build.report.metrics.ValueType
|
||||||
import org.jetbrains.kotlin.gradle.plugin.BuildEventsListenerRegistryHolder
|
import org.jetbrains.kotlin.gradle.plugin.BuildEventsListenerRegistryHolder
|
||||||
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
|
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
|
||||||
import org.jetbrains.kotlin.gradle.plugin.stat.BuildFinishStatisticsData
|
import org.jetbrains.kotlin.gradle.plugin.stat.BuildFinishStatisticsData
|
||||||
@@ -121,7 +121,7 @@ abstract class BuildReportsService : BuildService<BuildReportsService.Parameters
|
|||||||
.includeVerboseEnvironment(parameters.reportingSettings.get().httpReportSettings?.verboseEnvironment ?: false),
|
.includeVerboseEnvironment(parameters.reportingSettings.get().httpReportSettings?.verboseEnvironment ?: false),
|
||||||
buildUuid = buildUuid,
|
buildUuid = buildUuid,
|
||||||
label = parameters.label.orNull,
|
label = parameters.label.orNull,
|
||||||
totalTime = (System.nanoTime() - startTime) / 1_000_000,
|
totalTime = TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - startTime)),
|
||||||
finishTime = System.currentTimeMillis(),
|
finishTime = System.currentTimeMillis(),
|
||||||
hostName = hostName,
|
hostName = hostName,
|
||||||
tags = tags.toList(),
|
tags = tags.toList(),
|
||||||
@@ -249,13 +249,14 @@ abstract class BuildReportsService : BuildService<BuildReportsService.Parameters
|
|||||||
data.buildTimesMetrics.map { (key, value) -> "${key.readableString}: ${value}ms" } //sometimes it is better to have separate variable to be able debug
|
data.buildTimesMetrics.map { (key, value) -> "${key.readableString}: ${value}ms" } //sometimes it is better to have separate variable to be able debug
|
||||||
val perfData = data.performanceMetrics.map { (key, value) ->
|
val perfData = data.performanceMetrics.map { (key, value) ->
|
||||||
when (key.type) {
|
when (key.type) {
|
||||||
SizeMetricType.BYTES -> "${key.readableString}: ${formatSize(value)}"
|
ValueType.BYTES -> "${key.readableString}: ${formatSize(value)}"
|
||||||
|
ValueType.MILLISECONDS -> DATE_FORMATTER.format(value)
|
||||||
else -> "${key.readableString}: $value}"
|
else -> "${key.readableString}: $value}"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timeData.union(perfData).joinTo(readableString, ",", "Performance: [", "]")
|
timeData.union(perfData).joinTo(readableString, ",", "Performance: [", "]")
|
||||||
|
|
||||||
return splitStringIfNeed(readableString.toString(), lengthLimit)
|
return splitStringIfNeed(readableString.toString(), CUSTOM_VALUE_LENGTH_LIMIT)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun splitStringIfNeed(str: String, lengthLimit: Int): List<String> {
|
private fun splitStringIfNeed(str: String, lengthLimit: Int): List<String> {
|
||||||
@@ -287,7 +288,8 @@ abstract class BuildReportsService : BuildService<BuildReportsService.Parameters
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
const val lengthLimit = 100_000
|
const val CUSTOM_VALUE_LENGTH_LIMIT = 100_000
|
||||||
|
private val DATE_FORMATTER = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
|
||||||
|
|
||||||
fun getStartParameters(project: Project) = project.gradle.startParameter.let {
|
fun getStartParameters(project: Project) = project.gradle.startParameter.let {
|
||||||
GradleBuildStartParameters(
|
GradleBuildStartParameters(
|
||||||
|
|||||||
+2
-2
@@ -144,8 +144,8 @@ internal class PlainTextBuildReportWriter(
|
|||||||
|
|
||||||
repeat(indentLevel) { p.pushIndent() }
|
repeat(indentLevel) { p.pushIndent() }
|
||||||
when (sizeMetric.type) {
|
when (sizeMetric.type) {
|
||||||
SizeMetricType.BYTES -> p.println("${sizeMetric.readableString}: ${formatSize(value)}")
|
ValueType.BYTES -> p.println("${sizeMetric.readableString}: ${formatSize(value)}")
|
||||||
SizeMetricType.NUMBER -> p.println("${sizeMetric.readableString}: $value")
|
ValueType.NUMBER -> p.println("${sizeMetric.readableString}: $value")
|
||||||
}
|
}
|
||||||
repeat(indentLevel) { p.popIndent() }
|
repeat(indentLevel) { p.popIndent() }
|
||||||
}
|
}
|
||||||
|
|||||||
+68
-13
@@ -9,7 +9,7 @@ import org.gradle.tooling.events.task.TaskFailureResult
|
|||||||
import org.gradle.tooling.events.task.TaskFinishEvent
|
import org.gradle.tooling.events.task.TaskFinishEvent
|
||||||
import org.gradle.tooling.events.task.TaskSkippedResult
|
import org.gradle.tooling.events.task.TaskSkippedResult
|
||||||
import org.gradle.tooling.events.task.TaskSuccessResult
|
import org.gradle.tooling.events.task.TaskSuccessResult
|
||||||
import org.jetbrains.kotlin.build.report.metrics.BuildMetrics
|
import org.jetbrains.kotlin.build.report.metrics.*
|
||||||
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskExecutionResults
|
import org.jetbrains.kotlin.gradle.plugin.internal.state.TaskExecutionResults
|
||||||
import org.jetbrains.kotlin.gradle.plugin.stat.CompileStatisticsData
|
import org.jetbrains.kotlin.gradle.plugin.stat.CompileStatisticsData
|
||||||
import org.jetbrains.kotlin.gradle.plugin.stat.StatTag
|
import org.jetbrains.kotlin.gradle.plugin.stat.StatTag
|
||||||
@@ -18,6 +18,7 @@ import org.jetbrains.kotlin.incremental.ChangedFiles
|
|||||||
import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
|
import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
|
||||||
import java.lang.management.ManagementFactory
|
import java.lang.management.ManagementFactory
|
||||||
import java.util.ArrayList
|
import java.util.ArrayList
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
|
|
||||||
private fun availableForStat(taskPath: String): Boolean {
|
private fun availableForStat(taskPath: String): Boolean {
|
||||||
@@ -51,10 +52,13 @@ internal fun prepareData(
|
|||||||
if (!availableForStat(taskPath)) {
|
if (!availableForStat(taskPath)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
val buildMetrics = buildOperationRecords.firstOrNull { it.path == taskPath }?.buildMetrics
|
|
||||||
val taskExecutionResult = TaskExecutionResults[taskPath]
|
val taskExecutionResult = TaskExecutionResults[taskPath]
|
||||||
val buildTimesMs = buildMetrics?.buildTimes?.asMapMs()?.filterValues { value -> value != 0L } ?: emptyMap()
|
val buildMetrics = buildOperationRecords.firstOrNull { it.path == taskPath }?.buildMetrics
|
||||||
val perfData = buildMetrics?.buildPerformanceMetrics?.asMap()?.filterValues { value -> value != 0L } ?: emptyMap()
|
|
||||||
|
val performanceMetrics = collectBuildPerformanceMetrics(taskExecutionResult, buildMetrics)
|
||||||
|
val buildTimesMetrics = collectBuildMetrics(taskExecutionResult, buildMetrics, performanceMetrics, result.startTime, System.currentTimeMillis())
|
||||||
|
val buildAttributes = collectBuildAttributes(taskExecutionResult, buildMetrics)
|
||||||
|
|
||||||
val changes = when (val changedFiles = taskExecutionResult?.taskInfo?.changedFiles) {
|
val changes = when (val changedFiles = taskExecutionResult?.taskInfo?.changedFiles) {
|
||||||
is ChangedFiles.Known -> changedFiles.modified.map { it.absolutePath } + changedFiles.removed.map { it.absolutePath }
|
is ChangedFiles.Known -> changedFiles.modified.map { it.absolutePath } + changedFiles.removed.map { it.absolutePath }
|
||||||
else -> emptyList<String>()
|
else -> emptyList<String>()
|
||||||
@@ -63,14 +67,13 @@ internal fun prepareData(
|
|||||||
durationMs = durationMs,
|
durationMs = durationMs,
|
||||||
taskResult = taskResult.name,
|
taskResult = taskResult.name,
|
||||||
label = label,
|
label = label,
|
||||||
buildTimesMetrics = buildTimesMs,
|
buildTimesMetrics = buildTimesMetrics,
|
||||||
performanceMetrics = perfData,
|
performanceMetrics = performanceMetrics,
|
||||||
projectName = projectName,
|
projectName = projectName,
|
||||||
taskName = taskPath,
|
taskName = taskPath,
|
||||||
changes = changes,
|
changes = changes,
|
||||||
tags = parseTags(taskExecutionResult, buildMetrics, additionalTags).map { it.name },
|
tags = collectTags(taskExecutionResult, buildMetrics, additionalTags).map { it.name },
|
||||||
nonIncrementalAttributes = buildMetrics?.buildAttributes?.asMap()?.filter { it.value > 0 }?.keys
|
nonIncrementalAttributes = collectBuildAttributes(taskExecutionResult, buildMetrics),
|
||||||
?: emptySet(),
|
|
||||||
hostName = BuildReportsService.hostName,
|
hostName = BuildReportsService.hostName,
|
||||||
kotlinVersion = kotlinVersion,
|
kotlinVersion = kotlinVersion,
|
||||||
buildUuid = uuid,
|
buildUuid = uuid,
|
||||||
@@ -79,9 +82,61 @@ internal fun prepareData(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseTags(taskExecutionResult: TaskExecutionResult?, buildMetrics: BuildMetrics?, additionalTags: List<StatTag>): List<StatTag> {
|
private fun collectBuildAttributes(taskExecutionResult: TaskExecutionResult?, buildMetrics: BuildMetrics?): Set<BuildAttribute> {
|
||||||
val tags = parseTags(taskExecutionResult, additionalTags)
|
val attributes = HashSet<BuildAttribute>()
|
||||||
val nonIncrementalAttributes = buildMetrics?.buildAttributes?.asMap() ?: emptyMap()
|
buildMetrics?.buildAttributes?.asMap()?.filter { it.value > 0 }?.keys?.also { attributes.addAll(it) }
|
||||||
|
taskExecutionResult?.buildMetrics?.buildAttributes?.asMap()?.filter { it.value > 0 }?.keys?.also { attributes.addAll(it) }
|
||||||
|
return attributes
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun collectBuildPerformanceMetrics(
|
||||||
|
taskExecutionResult: TaskExecutionResult?,
|
||||||
|
buildMetrics: BuildMetrics?,
|
||||||
|
): Map<BuildPerformanceMetric, Long> {
|
||||||
|
val taskBuildPerformanceMetrics = HashMap<BuildPerformanceMetric, Long>()
|
||||||
|
taskExecutionResult?.buildMetrics?.buildPerformanceMetrics?.asMap()?.let { taskBuildPerformanceMetrics.putAll(it) }
|
||||||
|
buildMetrics?.buildPerformanceMetrics?.asMap()?.let { taskBuildPerformanceMetrics.putAll(it) }
|
||||||
|
taskBuildPerformanceMetrics.filterValues { value -> value != 0L }
|
||||||
|
return taskBuildPerformanceMetrics
|
||||||
|
}
|
||||||
|
private fun collectBuildMetrics(
|
||||||
|
taskExecutionResult: TaskExecutionResult?,
|
||||||
|
buildMetrics: BuildMetrics?,
|
||||||
|
performanceMetrics: Map<BuildPerformanceMetric, Long>,
|
||||||
|
gradleTaskStartTime: Long? = null,
|
||||||
|
taskFinishEventTime: Long? = null,
|
||||||
|
): Map<BuildTime, Long> {
|
||||||
|
val taskBuildMetrics = HashMap<BuildTime, Long>()
|
||||||
|
taskExecutionResult?.buildMetrics?.buildTimes?.asMapMs()?.let { taskBuildMetrics.putAll(it) }
|
||||||
|
buildMetrics?.buildTimes?.asMapMs()?.let { taskBuildMetrics.putAll(it) }
|
||||||
|
gradleTaskStartTime?.let { startTime ->
|
||||||
|
performanceMetrics[BuildPerformanceMetric.START_TASK_ACTION_EXECUTION]?.let { actionStartTime ->
|
||||||
|
taskBuildMetrics.put(BuildTime.GRADLE_TASK_PREPARATION, actionStartTime - startTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
taskFinishEventTime?.let { listenerNotificationTime ->
|
||||||
|
performanceMetrics[BuildPerformanceMetric.FINISH_KOTLIN_DAEMON_EXECUTION]?.let { daemonFinishTime ->
|
||||||
|
taskBuildMetrics.put(BuildTime.TASK_FINISH_LISTENER_NOTIFICATION, listenerNotificationTime - daemonFinishTime)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
performanceMetrics[BuildPerformanceMetric.CALL_WORKER]?.let { callWorkerTime ->
|
||||||
|
performanceMetrics[BuildPerformanceMetric.START_WORKER_EXECUTION]?.let { startWorkerExecutionTime ->
|
||||||
|
taskBuildMetrics.put(BuildTime.RUN_WORKER_DELAY, TimeUnit.NANOSECONDS.toMillis(startWorkerExecutionTime - callWorkerTime))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
taskBuildMetrics.filterValues { value -> value != 0L }
|
||||||
|
return taskBuildMetrics
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun collectTags(
|
||||||
|
taskExecutionResult: TaskExecutionResult?,
|
||||||
|
buildMetrics: BuildMetrics?,
|
||||||
|
additionalTags: List<StatTag>
|
||||||
|
): List<StatTag> {
|
||||||
|
val tags = collectTags(taskExecutionResult, additionalTags)
|
||||||
|
val nonIncrementalAttributes = collectBuildAttributes(taskExecutionResult, buildMetrics)
|
||||||
if (nonIncrementalAttributes.isEmpty()) {
|
if (nonIncrementalAttributes.isEmpty()) {
|
||||||
tags.add(StatTag.INCREMENTAL)
|
tags.add(StatTag.INCREMENTAL)
|
||||||
} else {
|
} else {
|
||||||
@@ -90,7 +145,7 @@ private fun parseTags(taskExecutionResult: TaskExecutionResult?, buildMetrics: B
|
|||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun parseTags(
|
private fun collectTags(
|
||||||
taskExecutionResult: TaskExecutionResult?,
|
taskExecutionResult: TaskExecutionResult?,
|
||||||
additionalTags: List<StatTag>,
|
additionalTags: List<StatTag>,
|
||||||
): MutableList<StatTag>{
|
): MutableList<StatTag>{
|
||||||
|
|||||||
+2
-1
@@ -388,7 +388,8 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments> @Inject constr
|
|||||||
@TaskAction
|
@TaskAction
|
||||||
fun execute(inputChanges: InputChanges) {
|
fun execute(inputChanges: InputChanges) {
|
||||||
val buildMetrics = metrics.get()
|
val buildMetrics = metrics.get()
|
||||||
buildMetrics.measure(BuildTime.GRADLE_TASK_ACTION) {
|
buildMetrics.addTimeMetric(BuildPerformanceMetric.START_TASK_ACTION_EXECUTION)
|
||||||
|
buildMetrics.measure(BuildTime.OUT_OF_WORKER_TASK_ACTION) {
|
||||||
KotlinBuildStatsService.applyIfInitialised {
|
KotlinBuildStatsService.applyIfInitialised {
|
||||||
if (name.contains("Test"))
|
if (name.contains("Test"))
|
||||||
it.report(BooleanMetrics.TESTS_EXECUTED, true)
|
it.report(BooleanMetrics.TESTS_EXECUTED, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user