Skip to content

Commit b4bab03

Browse files
committed
Let the heap increase a bit if we are thrashing
1 parent 4da775f commit b4bab03

File tree

2 files changed

+5
-258
lines changed

2 files changed

+5
-258
lines changed

batch.diff

Lines changed: 0 additions & 255 deletions
This file was deleted.

src/gc.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3279,7 +3279,8 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
32793279
if (sweep_full) {
32803280
gc_num.last_full_sweep = gc_end_time;
32813281
}
3282-
3282+
3283+
int thrashing = 0; // maybe we should report this to the user or error out?
32833284
size_t heap_size = jl_atomic_load_relaxed(&gc_heap_stats.heap_size);
32843285
double target_allocs = 0.0;
32853286
double min_interval = default_collect_interval;
@@ -3298,17 +3299,18 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
32983299
old_freed_diff = freed_diff;
32993300
old_pause_time = pause;
33003301
old_heap_size = heap_size;
3302+
thrashing = gc_time > mutator_time * 98 ? 1 : 0;
33013303
if (alloc_mem != 0 && alloc_time != 0 && gc_mem != 0 && gc_time != 0 ) {
33023304
double alloc_rate = alloc_mem/alloc_time;
33033305
double gc_rate = gc_mem/gc_time;
33043306
target_allocs = sqrt(((double)heap_size/min_interval * alloc_rate)/(gc_rate * tuning_factor)); // work on multiples of min interval
33053307
}
33063308
}
3307-
if (target_allocs == 0.0)
3309+
if (target_allocs == 0.0 || thrashing) // If we are thrashing go back to default
33083310
target_allocs = 2*sqrt((double)heap_size/min_interval);
33093311

33103312
uint64_t target_heap = (uint64_t)target_allocs*min_interval + heap_size;
3311-
if (target_heap > max_total_memory)
3313+
if (target_heap > max_total_memory && !thrashing) // Allow it to go over if we are thrashing if we die we die
33123314
target_heap = max_total_memory;
33133315
else if (target_heap < default_collect_interval)
33143316
target_heap = default_collect_interval;

0 commit comments

Comments
 (0)