[K/N] Adjust values for the initial and minimum heap sizes ^KT-61092

This commit is contained in:
Alexander Shabalin
2023-08-09 15:41:24 +02:00
committed by Space Team
parent 5ee50f50b5
commit efa59eb589
2 changed files with 10 additions and 4 deletions
@@ -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<int64_t> targetHeapBytes = 1024 * 1024;
std::atomic<int64_t> 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<double> targetHeapUtilization = 0.5;
// The minimum value of `targetHeapBytes` for `autoTune = true`
std::atomic<int64_t> minHeapBytes = 1024 * 1024;
std::atomic<int64_t> 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<int64_t> maxHeapBytes = std::numeric_limits<int64_t>::max();
// GC will be triggered when object bytes reach `heapTriggerCoefficient * targetHeapBytes`.
@@ -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.
*