mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
gc.c: use :debt instead of :threshold in GC.stat
Expose gc_debt directly as :debt in GC.stat without sign negation. The debt model has no threshold ceiling, so :threshold was a misleading name. Negative debt means credit, positive means GC is behind on collection work. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -384,7 +384,7 @@ GC.disable # disable GC
|
||||
GC.stat
|
||||
# => {
|
||||
# :live => 5432, # live object count
|
||||
# :threshold => 1024, # GC credit (positive=headroom)
|
||||
# :debt => -1024, # GC debt (negative=credit, positive=behind)
|
||||
# :state => 0, # 0=root, 1=marking, 2=sweeping
|
||||
# :generational => true, # generational mode enabled
|
||||
# :full => false, # major GC in progress
|
||||
|
||||
@@ -1785,7 +1785,7 @@ mrb_objspace_page_slot_size(void)
|
||||
* GC.stat -> Hash
|
||||
*
|
||||
* Returns a Hash with GC statistics.
|
||||
* Keys: :live, :threshold, :state, :generational, :full,
|
||||
* Keys: :live, :debt, :state, :generational, :full,
|
||||
* :step_limit, :malloc_increase, :malloc_threshold
|
||||
* With MRB_GC_STATS: :total, :minor, :major
|
||||
*
|
||||
@@ -1798,7 +1798,7 @@ gc_stat(mrb_state *mrb, mrb_value self)
|
||||
mrb_value hash = mrb_hash_new_capa(mrb, 8);
|
||||
|
||||
mrb_hash_set(mrb, hash, mrb_symbol_value(mrb_intern_lit(mrb, "live")), mrb_int_value(mrb, (mrb_int)gc->live));
|
||||
mrb_hash_set(mrb, hash, mrb_symbol_value(mrb_intern_lit(mrb, "threshold")), mrb_int_value(mrb, -gc->gc_debt));
|
||||
mrb_hash_set(mrb, hash, mrb_symbol_value(mrb_intern_lit(mrb, "debt")), mrb_int_value(mrb, gc->gc_debt));
|
||||
mrb_hash_set(mrb, hash, mrb_symbol_value(mrb_intern_lit(mrb, "state")), mrb_int_value(mrb, (mrb_int)gc->state));
|
||||
mrb_hash_set(mrb, hash, mrb_symbol_value(mrb_intern_lit(mrb, "generational")), mrb_bool_value(gc->generational));
|
||||
mrb_hash_set(mrb, hash, mrb_symbol_value(mrb_intern_lit(mrb, "full")), mrb_bool_value(gc->full));
|
||||
|
||||
Reference in New Issue
Block a user