Feature #2837 ยป grow_factor.patch
gc.c (working copy) | ||
---|---|---|
#define HEAP_MIN_SLOTS 10000
|
||
#define FREE_MIN 4096
|
||
#define HEAP_GROW_FACTOR 1.8
|
||
static float HEAP_GROW_FACTOR_VAL = HEAP_GROW_FACTOR;
|
||
struct gc_list {
|
||
VALUE *varptr;
|
||
struct gc_list *next;
|
||
... | ... | |
static void
|
||
set_heaps_increment(rb_objspace_t *objspace)
|
||
{
|
||
size_t next_heaps_length = (size_t)(heaps_used * 1.8);
|
||
size_t next_heaps_length = (size_t)(heaps_used * HEAP_GROW_FACTOR_VAL);
|
||
if (next_heaps_length == heaps_used) {
|
||
next_heaps_length++;
|
||
... | ... | |
return UINT2NUM((&rb_objspace)->count);
|
||
}
|
||
/*
|
||
* call-seq:
|
||
* GC.heap_growth_factor -> Float
|
||
*
|
||
* The rate by which we increase the size of each subsequently allocated heap.
|
||
*
|
||
* It returns the rate by which we increase the size of each subsequently allocated heap.
|
||
*/
|
||
|
||
static VALUE
|
||
gc_heap_growth_factor_get(VALUE self)
|
||
{
|
||
return rb_float_new(HEAP_GROW_FACTOR_VAL);
|
||
}
|
||
/*
|
||
*
|
||
* call-seq:
|
||
* GC.heap_growth_factor = Float -> Float
|
||
*
|
||
* Updates the minimum number of slots in each heap slab.
|
||
*
|
||
* It returns the new number of slots to allocate for each heap slab.
|
||
*/
|
||
|
||
static VALUE
|
||
gc_heap_growth_factor_set(VALUE self, VALUE new_factor)
|
||
{
|
||
HEAP_GROW_FACTOR_VAL = RFLOAT_VALUE(new_factor);
|
||
return new_factor;
|
||
}
|
||
#if CALC_EXACT_MALLOC_SIZE
|
||
/*
|
||
* call-seq:
|
||
... | ... | |
rb_define_singleton_method(rb_mGC, "stress", gc_stress_get, 0);
|
||
rb_define_singleton_method(rb_mGC, "stress=", gc_stress_set, 1);
|
||
rb_define_singleton_method(rb_mGC, "count", gc_count, 0);
|
||
rb_define_singleton_method(rb_mGC, "heap_growth_factor", gc_heap_growth_factor_get, 0);
|
||
rb_define_singleton_method(rb_mGC, "heap_growth_factor=", gc_heap_growth_factor_set, 1);
|
||
rb_define_method(rb_mGC, "garbage_collect", rb_gc_start, 0);
|
||
rb_mProfiler = rb_define_module_under(rb_mGC, "Profiler");
|