diff --git a/kotlin-native/backend.native/tests/build.gradle b/kotlin-native/backend.native/tests/build.gradle index 9fba27cb847..f29bbdc31a8 100644 --- a/kotlin-native/backend.native/tests/build.gradle +++ b/kotlin-native/backend.native/tests/build.gradle @@ -2970,6 +2970,12 @@ standaloneTest("leakMemoryWithTestRunner") { } standaloneTest("stress_gc_allocations") { + // TODO: Support obtaining peak RSS on more platforms. + enabled = (project.testTarget != "wasm32") && + (project.testTarget != "watchos_arm32") && + (project.testTarget != "watchos_arm64") && + (project.testTarget != "watchos_x86") && + (project.testTarget != "watchos_x64") source = "runtime/memory/stress_gc_allocations.kt" flags = ['-tr', '-Xopt-in=kotlin.native.internal.InternalForKotlinNative'] } diff --git a/kotlin-native/backend.native/tests/runtime/memory/stress_gc_allocations.kt b/kotlin-native/backend.native/tests/runtime/memory/stress_gc_allocations.kt index 035b965a314..22d7b9e55aa 100644 --- a/kotlin-native/backend.native/tests/runtime/memory/stress_gc_allocations.kt +++ b/kotlin-native/backend.native/tests/runtime/memory/stress_gc_allocations.kt @@ -8,10 +8,11 @@ import kotlin.native.concurrent.* import kotlin.native.internal.MemoryUsageInfo object Blackhole { - private val hole = AtomicLong(0) + // On MIPS `AtomicLong` does not support `addAndGet`. TODO: Fix it. + private val hole = AtomicInt(0) fun consume(value: Any) { - hole.addAndGet(value.hashCode()) + hole.addAndGet(value.hashCode().toInt()) } fun discharge() { @@ -50,8 +51,8 @@ fun test() { val value: Byte = 42 // Try to make sure each page is written val stride = 4096 - // Limit memory usage at ~200MiB - val rssDiffLimit: Long = 200_000_000 + // Limit memory usage at ~500MiB. This limit was exercised by -Xallocator=mimalloc and legacy MM. + val rssDiffLimit: Long = 500_000_000 // Trigger GC after ~100MiB are allocated val retainLimit: Long = 100_000_000 val progressReportsCount = 100