Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Conservative Incremental GC Scheduling #4161

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions rts/motoko-rts/src/gc/incremental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,32 @@ unsafe fn should_start() -> bool {
use self::partitioned_heap::PARTITION_SIZE;
use crate::memory::ic::partitioned_memory;

const CRITICAL_HEAP_LIMIT: Bytes<u32> = Bytes(u32::MAX - 768 * 1024 * 1024);
const CRITICAL_GROWTH_THRESHOLD: f64 = 0.01;
const NORMAL_GROWTH_THRESHOLD: f64 = 0.65;

let heap_size = partitioned_memory::get_heap_size();
let growth_threshold = if heap_size > CRITICAL_HEAP_LIMIT {
CRITICAL_GROWTH_THRESHOLD
} else {
NORMAL_GROWTH_THRESHOLD
};
if heap_size.as_usize() < PARTITION_SIZE {
return false;
}

const ABSOLUT_GROWTH_THRESHOLD: Bytes<u64> = Bytes(512 * 1024 * 1024);
luc-blaeser marked this conversation as resolved.
Show resolved Hide resolved

let current_allocations = partitioned_memory::get_total_allocations();
debug_assert!(current_allocations >= LAST_ALLOCATIONS);
let absolute_growth = current_allocations - LAST_ALLOCATIONS;
if absolute_growth > ABSOLUT_GROWTH_THRESHOLD {
luc-blaeser marked this conversation as resolved.
Show resolved Hide resolved
return true;
}

const CRITICAL_HEAP_LIMIT: Bytes<u32> = Bytes(u32::MAX - 768 * 1024 * 1024);
const CRITICAL_RELATIVE_GROWTH_THRESHOLD: f64 = 0.01;
const NORMAL_RELATIVE_GROWTH_THRESHOLD: f64 = 0.65;

let relative_growth_threshold = if heap_size > CRITICAL_HEAP_LIMIT {
CRITICAL_RELATIVE_GROWTH_THRESHOLD
} else {
NORMAL_RELATIVE_GROWTH_THRESHOLD
};

let relative_growth = absolute_growth.0 as f64 / heap_size.as_usize() as f64;
relative_growth > growth_threshold && heap_size.as_usize() >= PARTITION_SIZE
relative_growth > relative_growth_threshold
}

#[cfg(feature = "ic")]
Expand Down
Loading