mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
gc.c: replace threshold model with debt-based GC trigger
Replace the threshold-based GC trigger (gc->threshold vs gc->live) with a debt model (gc->gc_debt). Each allocation increments debt; each GC step decrements by GC_STEP_SIZE. When a cycle completes, credit is proportional to live_after_mark * interval_ratio, giving a natural feedback loop that adapts to allocation rate. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -45,7 +45,7 @@ typedef struct mrb_gc {
|
||||
mrb_bool gray_overflow:1; /* gray stack overflowed; needs heap rescan */
|
||||
size_t live; /* count of live objects */
|
||||
size_t live_after_mark; /* old generation objects */
|
||||
size_t threshold; /* threshold to start GC */
|
||||
mrb_int gc_debt; /* <0:credit, >0:needs GC */
|
||||
size_t oldgen_threshold; /* threshold to kick major GC */
|
||||
mrb_gc_state state; /* current state of gc */
|
||||
int interval_ratio;
|
||||
|
||||
Reference in New Issue
Block a user