Skip to content

Commit

Permalink
Improve thrashing detection
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaraldi committed Aug 1, 2023
1 parent 3bf6fd9 commit c5d98df
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ static uint64_t old_heap_size = 0;
static uint64_t old_alloc_diff = 0;
static uint64_t old_freed_diff = 0;
static uint64_t gc_end_time = 0;

static int thrash_counter = 0;

// global variables for GC stats

Expand Down Expand Up @@ -3324,7 +3324,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
gc_num.last_incremental_sweep = gc_end_time;
}

int thrashing = 0; // maybe we should report this to the user or error out?
int thrashing = thrash_counter > 4; // maybe we should report this to the user or error out?
size_t heap_size = jl_atomic_load_relaxed(&gc_heap_stats.heap_size);
double target_allocs = 0.0;
double min_interval = default_collect_interval;
Expand All @@ -3343,7 +3343,10 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
old_freed_diff = freed_diff;
old_pause_time = pause;
old_heap_size = heap_size; // TODO: Update these values dynamically instead of just during the GC
thrashing = gc_time > mutator_time * 98 ? 1 : 0;
if (gc_time > alloc_time * 95)
thrash_counter += 1;
else
thrash_counter = 0;
if (alloc_mem != 0 && alloc_time != 0 && gc_mem != 0 && gc_time != 0 ) {
double alloc_rate = alloc_mem/alloc_time;
double gc_rate = gc_mem/gc_time;
Expand Down

0 comments on commit c5d98df

Please sign in to comment.