Skip to content

Commit

Permalink
[Wasm] Add statistic collection for Wasm IC
Browse files Browse the repository at this point in the history
^KT-71506 fixed
  • Loading branch information
ilgonmic authored and qodana-bot committed Sep 24, 2024
1 parent e448d67 commit a53d78b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import org.jetbrains.kotlin.gradle.report.BuildReportType
import org.jetbrains.kotlin.gradle.testbase.*
import org.jetbrains.kotlin.gradle.testbase.BuildOptions.IsolatedProjectsMode
import org.jetbrains.kotlin.gradle.util.replaceText
import org.jetbrains.kotlin.test.TestMetadata
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.condition.OS
import java.nio.file.Files
import java.nio.file.Path
import kotlin.io.path.deleteIfExists
import kotlin.io.path.writeText
import kotlin.streams.toList
import kotlin.test.assertTrue

Expand Down Expand Up @@ -370,6 +372,30 @@ class FusStatisticsIT : KGPBaseTest() {
}
}

@MppGradlePluginTests
@GradleTest
fun testWasmIncrementalStatisticCollection(gradleVersion: GradleVersion) {
project(
"new-mpp-wasm-test", gradleVersion
) {
gradleProperties.writeText("kotlin.incremental.wasm=true")

buildGradleKts.modify {
it
.replace("wasmJs {", "wasmJs {\nbinaries.executable()")
.replace("<JsEngine>", "nodejs")
}

build("compileDevelopmentExecutableKotlinWasmJs", "-Pkotlin.session.logger.root.path=$projectPath") {
assertTasksExecuted(":compileDevelopmentExecutableKotlinWasmJs")
assertFileContains(
fusStatisticsPath,
"WASM_IR_INCREMENTAL=true",
)
}
}
}

private fun TestProject.applyDokka() {
buildGradle.replaceText(
"plugins {",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ internal object CompileKotlinJsIrLinkMetrics : FusMetrics {
}
}

internal object CompileKotlinWasmIrLinkMetrics : FusMetrics {
internal fun collectMetrics(
incrementalWasm: Boolean,
metricsConsumer: StatisticsValuesConsumer,
) {
metricsConsumer.report(BooleanMetrics.WASM_IR_INCREMENTAL, incrementalWasm)
}
}


internal object KotlinMetadataConfigurationMetrics : FusMetrics {
internal fun collectMetrics(metricContainer: MetricContainer) {
metricContainer.put(BooleanMetrics.ENABLED_HMPP, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import org.gradle.work.NormalizeLineEndings
import org.gradle.workers.WorkerExecutor
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.gradle.InternalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompilerOptionsDefault
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilerArgumentsProducer.ContributeCompilerArgumentsContext
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
import org.jetbrains.kotlin.gradle.plugin.statistics.CompileKotlinJsIrLinkMetrics
import org.jetbrains.kotlin.gradle.plugin.statistics.CompileKotlinWasmIrLinkMetrics
import org.jetbrains.kotlin.gradle.plugin.statistics.UsesBuildFusService
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode.DEVELOPMENT
Expand Down Expand Up @@ -135,6 +135,10 @@ abstract class KotlinJsIrLink @Inject constructor(
buildFusService.orNull?.reportFusMetrics {
CompileKotlinJsIrLinkMetrics.collectMetrics(args, incrementalJsIr, it)
}
} else {
buildFusService.orNull?.reportFusMetrics {
CompileKotlinWasmIrLinkMetrics.collectMetrics(incrementalWasm, it)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ enum class BooleanMetrics(val type: BooleanOverridePolicy, val anonymization: Bo

JS_IR_INCREMENTAL(OR, SAFE),

WASM_IR_INCREMENTAL(OR, SAFE),

//Build reports
FILE_BUILD_REPORT(OR, SAFE),
BUILD_SCAN_BUILD_REPORT(OR, SAFE),
Expand Down Expand Up @@ -93,6 +95,6 @@ enum class BooleanMetrics(val type: BooleanOverridePolicy, val anonymization: Bo
;

companion object {
const val VERSION = 10
const val VERSION = 11
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private const val STRING_METRICS_RELATIVE_PATH = "$SOURCE_CODE_RELATIVE_PATH/Str
private const val NUMERICAL_METRICS_RELATIVE_PATH = "$SOURCE_CODE_RELATIVE_PATH/NumericalMetrics.kt"

private val STRING_METRICS_EXPECTED_VERSION_AND_HASH = Pair(2, "636529439256b809cd4fb99e20310505")
private val BOOLEAN_METRICS_EXPECTED_VERSION_AND_HASH = Pair(10, "2fc50dacfafd4f4b796ac76f2ce7cc16")
private val BOOLEAN_METRICS_EXPECTED_VERSION_AND_HASH = Pair(11, "90b586ea9ab1f5bf387c185248166cfd")
private val NUMERICAL_METRICS_EXPECTED_VERSION_AND_HASH = Pair(2, "d8c1a1f4fb7227fbe8247320bf3370ca")
private val SOURCE_FOLDER_EXPECTED_VERSION_AND_HASH =
Pair(
Expand Down

0 comments on commit a53d78b

Please sign in to comment.