diff --git a/kotlin-native/runtime/src/gcScheduler/common/cpp/GCSchedulerConfig.hpp b/kotlin-native/runtime/src/gcScheduler/common/cpp/GCSchedulerConfig.hpp index ff06201bc12..83e06dce2ad 100644 --- a/kotlin-native/runtime/src/gcScheduler/common/cpp/GCSchedulerConfig.hpp +++ b/kotlin-native/runtime/src/gcScheduler/common/cpp/GCSchedulerConfig.hpp @@ -11,6 +11,12 @@ namespace kotlin::gcScheduler { +#if KONAN_WATCHOS +constexpr int64_t kDefaultTargetHeapBytes = 10 * 1024 * 1024; +#else +constexpr int64_t kDefaultTargetHeapBytes = 100 * 1024 * 1024; +#endif + // NOTE: When changing default values, reflect them in GC.kt as well. struct GCSchedulerConfig { enum class MutatorAssists { @@ -27,13 +33,13 @@ struct GCSchedulerConfig { // become bigger than this value, and `mutatorAssists` are enabled the GC will // stop the world and wait until current epoch finishes. // Adapts after each GC epoch when `autoTune = true`. - std::atomic targetHeapBytes = 1024 * 1024; + std::atomic targetHeapBytes = kDefaultTargetHeapBytes; // The rate at which `targetHeapBytes` changes when `autoTune = true`. Concretely: if after the collection // `N` object bytes remain in the heap, the next `targetHeapBytes` will be `N / targetHeapUtilization` capped // between `minHeapBytes` and `maxHeapBytes`. std::atomic targetHeapUtilization = 0.5; // The minimum value of `targetHeapBytes` for `autoTune = true` - std::atomic minHeapBytes = 1024 * 1024; + std::atomic minHeapBytes = 5 * 1024 * 1024; // In `custom` allocator pages are 256KiB. 5MiB here is 20 pages. // The maximum value of `targetHeapBytes` for `autoTune = true` std::atomic maxHeapBytes = std::numeric_limits::max(); // GC will be triggered when object bytes reach `heapTriggerCoefficient * targetHeapBytes`. diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GC.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GC.kt index 98987254792..c8d30be9234 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GC.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/native/runtime/GC.kt @@ -201,7 +201,7 @@ public object GC { * Note, that if after a collection heapBytes > [targetHeapBytes] (which may happen if [autotune] is false, * or [maxHeapBytes] is set too low), the next collection will be triggered almost immediately. * - * Default: 1 MiB + * Default: 100 MiB (10 MiB on watchOS) * * Unused in legacy MM. * @@ -235,7 +235,7 @@ public object GC { * The minimum value for [targetHeapBytes] * Only used if [autotune] is true. See [targetHeapBytes] for more details. * - * Default: 1 MiB + * Default: 5 MiB * * Unused in legacy MM. *