Fix GC stress test.
This commit is contained in:
committed by
Space
parent
cf660cf24a
commit
ebc4e10684
@@ -2970,6 +2970,12 @@ standaloneTest("leakMemoryWithTestRunner") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
standaloneTest("stress_gc_allocations") {
|
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"
|
source = "runtime/memory/stress_gc_allocations.kt"
|
||||||
flags = ['-tr', '-Xopt-in=kotlin.native.internal.InternalForKotlinNative']
|
flags = ['-tr', '-Xopt-in=kotlin.native.internal.InternalForKotlinNative']
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,11 @@ import kotlin.native.concurrent.*
|
|||||||
import kotlin.native.internal.MemoryUsageInfo
|
import kotlin.native.internal.MemoryUsageInfo
|
||||||
|
|
||||||
object Blackhole {
|
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) {
|
fun consume(value: Any) {
|
||||||
hole.addAndGet(value.hashCode())
|
hole.addAndGet(value.hashCode().toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun discharge() {
|
fun discharge() {
|
||||||
@@ -50,8 +51,8 @@ fun test() {
|
|||||||
val value: Byte = 42
|
val value: Byte = 42
|
||||||
// Try to make sure each page is written
|
// Try to make sure each page is written
|
||||||
val stride = 4096
|
val stride = 4096
|
||||||
// Limit memory usage at ~200MiB
|
// Limit memory usage at ~500MiB. This limit was exercised by -Xallocator=mimalloc and legacy MM.
|
||||||
val rssDiffLimit: Long = 200_000_000
|
val rssDiffLimit: Long = 500_000_000
|
||||||
// Trigger GC after ~100MiB are allocated
|
// Trigger GC after ~100MiB are allocated
|
||||||
val retainLimit: Long = 100_000_000
|
val retainLimit: Long = 100_000_000
|
||||||
val progressReportsCount = 100
|
val progressReportsCount = 100
|
||||||
|
|||||||
Reference in New Issue
Block a user