Split Gradle and JPS metrics
#KT-58026 In progress
This commit is contained in:
committed by
Space Team
parent
524df83265
commit
ed2dd4b2ae
@@ -23,6 +23,8 @@ import org.jetbrains.kotlin.build.GeneratedJvmClass
|
||||
import org.jetbrains.kotlin.build.report.ICReporter.ReportSeverity
|
||||
import org.jetbrains.kotlin.build.report.ICReporterBase
|
||||
import org.jetbrains.kotlin.build.report.debug
|
||||
import org.jetbrains.kotlin.build.report.metrics.BuildTime
|
||||
import org.jetbrains.kotlin.build.report.metrics.JpsBuildTime
|
||||
import org.jetbrains.kotlin.cli.common.ExitCode
|
||||
import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
|
||||
@@ -323,12 +325,12 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
val proposedExitCode =
|
||||
doBuild(chunk, kotlinTarget, context, kotlinDirtyFilesHolder, messageCollector, outputConsumer, fsOperations)
|
||||
|
||||
val actualExitCode = if (proposedExitCode == OK && fsOperations.hasMarkedDirty) ADDITIONAL_PASS_REQUIRED else proposedExitCode
|
||||
val actualExitCode =
|
||||
if (proposedExitCode == OK && fsOperations.hasMarkedDirty) ADDITIONAL_PASS_REQUIRED else proposedExitCode
|
||||
|
||||
LOG.debug("Build result: $actualExitCode")
|
||||
|
||||
context.testingContext?.buildLogger?.buildFinished(actualExitCode)
|
||||
|
||||
return actualExitCode
|
||||
} catch (e: StopBuildException) {
|
||||
LOG.info("Caught exception: $e")
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.statistic
|
||||
|
||||
import org.jetbrains.kotlin.build.report.metrics.BuildAttribute
|
||||
import org.jetbrains.kotlin.build.report.metrics.JpsBuildPerformanceMetric
|
||||
import org.jetbrains.kotlin.build.report.metrics.JpsBuildTime
|
||||
import org.jetbrains.kotlin.build.report.statistics.CompileStatisticsData
|
||||
import org.jetbrains.kotlin.build.report.statistics.StatTag
|
||||
|
||||
class JpsCompileStatisticsData(
|
||||
private val projectName: String?,
|
||||
private val label: String?,
|
||||
private val taskName: String,
|
||||
private val taskResult: String?,
|
||||
private val startTimeMs: Long,
|
||||
private val durationMs: Long,
|
||||
private val tags: Set<StatTag>,
|
||||
private val changes: List<String>,
|
||||
private val buildUuid: String = "Unset",
|
||||
private val kotlinVersion: String,
|
||||
private val kotlinLanguageVersion: String?,
|
||||
private val hostName: String? = "Unset",
|
||||
private val finishTime: Long,
|
||||
private val compilerArguments: List<String>,
|
||||
private val nonIncrementalAttributes: Set<BuildAttribute>,
|
||||
private val buildTimesMetrics: Map<JpsBuildTime, Long>,
|
||||
private val performanceMetrics: Map<JpsBuildPerformanceMetric, Long>,
|
||||
private val gcTimeMetrics: Map<String, Long>?,
|
||||
private val gcCountMetrics: Map<String, Long>?,
|
||||
private val type: String,
|
||||
private val fromKotlinPlugin: Boolean?,
|
||||
private val compiledSources: List<String> = emptyList(),
|
||||
private val skipMessage: String?,
|
||||
private val icLogLines: List<String>,
|
||||
) : CompileStatisticsData<JpsBuildTime, JpsBuildPerformanceMetric> {
|
||||
override fun getProjectName(): String? = projectName
|
||||
override fun getLabel(): String? = label
|
||||
|
||||
override fun getTaskName(): String = taskName
|
||||
|
||||
override fun getTaskResult(): String? = taskResult
|
||||
|
||||
override fun getStartTimeMs(): Long = startTimeMs
|
||||
|
||||
override fun getDurationMs(): Long = durationMs
|
||||
|
||||
override fun getTags(): Set<StatTag> = tags
|
||||
|
||||
override fun getChanges(): List<String> = changes
|
||||
|
||||
override fun getKotlinVersion(): String = kotlinVersion
|
||||
|
||||
override fun getKotlinLanguageVersion(): String? = kotlinLanguageVersion
|
||||
|
||||
override fun getFinishTime(): Long = finishTime
|
||||
|
||||
override fun getCompilerArguments(): List<String> = compilerArguments
|
||||
|
||||
override fun getNonIncrementalAttributes(): Set<BuildAttribute> = nonIncrementalAttributes
|
||||
|
||||
override fun getBuildTimesMetrics(): Map<JpsBuildTime, Long> = buildTimesMetrics
|
||||
|
||||
override fun getPerformanceMetrics(): Map<JpsBuildPerformanceMetric, Long> = performanceMetrics
|
||||
|
||||
override fun getGcTimeMetrics(): Map<String, Long>? = gcTimeMetrics
|
||||
|
||||
override fun getGcCountMetrics(): Map<String, Long>? = gcCountMetrics
|
||||
|
||||
override fun getFromKotlinPlugin(): Boolean? = fromKotlinPlugin
|
||||
|
||||
override fun getSkipMessage(): String? = skipMessage
|
||||
|
||||
override fun getIcLogLines(): List<String> = icLogLines
|
||||
}
|
||||
+22
-9
@@ -17,13 +17,13 @@ import java.io.File
|
||||
import java.util.*
|
||||
import java.net.InetAddress
|
||||
|
||||
interface JpsBuilderMetricReporter : BuildMetricsReporter {
|
||||
fun flush(context: CompileContext): CompileStatisticsData
|
||||
interface JpsBuilderMetricReporter : BuildMetricsReporter<JpsBuildTime, JpsBuildPerformanceMetric> {
|
||||
fun flush(context: CompileContext): JpsCompileStatisticsData
|
||||
}
|
||||
|
||||
private const val jpsBuildTaskName = "JPS build"
|
||||
|
||||
class JpsBuilderMetricReporterImpl(private val reporter: BuildMetricsReporterImpl) : JpsBuilderMetricReporter, BuildMetricsReporter by reporter {
|
||||
class JpsBuilderMetricReporterImpl(private val reporter: BuildMetricsReporterImpl<JpsBuildTime, JpsBuildPerformanceMetric>) : JpsBuilderMetricReporter, BuildMetricsReporter<JpsBuildTime, JpsBuildPerformanceMetric> by reporter {
|
||||
|
||||
companion object {
|
||||
private val hostName: String? = try {
|
||||
@@ -37,9 +37,10 @@ class JpsBuilderMetricReporterImpl(private val reporter: BuildMetricsReporterImp
|
||||
private val uuid = UUID.randomUUID()
|
||||
private val startTime = System.currentTimeMillis()
|
||||
|
||||
override fun flush(context: CompileContext): CompileStatisticsData {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
override fun flush(context: CompileContext): JpsCompileStatisticsData {
|
||||
val buildMetrics = reporter.getMetrics()
|
||||
return CompileStatisticsData(
|
||||
return JpsCompileStatisticsData(
|
||||
projectName = context.projectDescriptor.project.name,
|
||||
label = "JPS build", //TODO will be updated in KT-58026
|
||||
taskName = jpsBuildTaskName,
|
||||
@@ -98,7 +99,7 @@ class JpsStatisticsReportService {
|
||||
if (contextMetrics[context] != null) {
|
||||
log.error("Service already initialized for context")
|
||||
}
|
||||
contextMetrics[context] = JpsBuilderMetricReporterImpl(BuildMetricsReporterImpl())
|
||||
contextMetrics[context] = JpsBuilderMetricReporterImpl(BuildMetricsReporterImpl<JpsBuildTime, JpsBuildPerformanceMetric>())
|
||||
}
|
||||
|
||||
fun buildFinished(context: CompileContext) {
|
||||
@@ -111,11 +112,23 @@ class JpsStatisticsReportService {
|
||||
val compileStatisticsData = metrics.flush(context)
|
||||
httpService?.sendData(compileStatisticsData, loggerAdapter)
|
||||
fileReportSettings?.also {
|
||||
FileReportService(it.buildReportDir, true, loggerAdapter)
|
||||
.process(listOf(compileStatisticsData),
|
||||
BuildStartParameters(tasks = listOf(jpsBuildTaskName)))
|
||||
FileReportService<JpsBuildTime, JpsBuildPerformanceMetric>(it.buildReportDir, true, loggerAdapter)
|
||||
.process(
|
||||
listOf(compileStatisticsData),
|
||||
BuildStartParameters(tasks = listOf(jpsBuildTaskName))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> reportMetrics(context: CompileContext, metric: JpsBuildTime, action: () -> T): T {
|
||||
val metrics = contextMetrics.remove(context)
|
||||
if (metrics == null) {
|
||||
log.error("Service hasn't initialized for context")
|
||||
return action.invoke()
|
||||
}
|
||||
return metrics.measure(metric, action)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user