Project

General

Profile

Bug #4547 ยป reflect_ruby_heap_min_slots.patch

authorNari (Narihiro Nakamura), 04/01/2011 05:46 PM

View differences:

gc.c
static unsigned int initial_heap_min_slots = HEAP_MIN_SLOTS;
static unsigned int initial_free_min = FREE_MIN;
void
rb_gc_set_params(void)
{
char *malloc_limit_ptr, *heap_min_slots_ptr, *free_min_ptr;
if (rb_safe_level() > 0) return;
malloc_limit_ptr = getenv("RUBY_GC_MALLOC_LIMIT");
if (malloc_limit_ptr != NULL) {
int malloc_limit_i = atoi(malloc_limit_ptr);
printf("malloc_limit=%d (%d)\n", malloc_limit_i, initial_malloc_limit);
if (malloc_limit_i > 0) {
initial_malloc_limit = malloc_limit_i;
}
}
heap_min_slots_ptr = getenv("RUBY_HEAP_MIN_SLOTS");
if (heap_min_slots_ptr != NULL) {
int heap_min_slots_i = atoi(heap_min_slots_ptr);
printf("heap_min_slots=%d (%d)\n", heap_min_slots_i, initial_heap_min_slots);
if (heap_min_slots_i > 0) {
initial_heap_min_slots = heap_min_slots_i;
}
}
free_min_ptr = getenv("RUBY_FREE_MIN");
if (free_min_ptr != NULL) {
int free_min_i = atoi(free_min_ptr);
printf("free_min=%d (%d)\n", free_min_i, initial_free_min);
if (free_min_i > 0) {
initial_free_min = free_min_i;
}
}
}
#define nomem_error GET_VM()->special_exceptions[ruby_error_nomemory]
#define MARK_STACK_MAX 1024
......
return objspace;
}
static void initial_expand_heap(rb_objspace_t *objspace);
void
rb_gc_set_params(void)
{
char *malloc_limit_ptr, *heap_min_slots_ptr, *free_min_ptr;
if (rb_safe_level() > 0) return;
malloc_limit_ptr = getenv("RUBY_GC_MALLOC_LIMIT");
if (malloc_limit_ptr != NULL) {
int malloc_limit_i = atoi(malloc_limit_ptr);
printf("malloc_limit=%d (%d)\n", malloc_limit_i, initial_malloc_limit);
if (malloc_limit_i > 0) {
initial_malloc_limit = malloc_limit_i;
}
}
heap_min_slots_ptr = getenv("RUBY_HEAP_MIN_SLOTS");
if (heap_min_slots_ptr != NULL) {
int heap_min_slots_i = atoi(heap_min_slots_ptr);
printf("heap_min_slots=%d (%d)\n", heap_min_slots_i, initial_heap_min_slots);
if (heap_min_slots_i > 0) {
initial_heap_min_slots = heap_min_slots_i;
}
}
free_min_ptr = getenv("RUBY_FREE_MIN");
if (free_min_ptr != NULL) {
int free_min_i = atoi(free_min_ptr);
printf("free_min=%d (%d)\n", free_min_i, initial_free_min);
if (free_min_i > 0) {
initial_free_min = free_min_i;
}
}
initial_expand_heap(&rb_objspace);
}
static void gc_sweep(rb_objspace_t *);
static void slot_sweep(rb_objspace_t *, struct heaps_slot *);
static void gc_clear_mark_on_sweep_slots(rb_objspace_t *);
......
}
static void
init_heap(rb_objspace_t *objspace)
add_heap_slots(rb_objspace_t *objspace, int add)
{
size_t add, i;
int i;
add = initial_heap_min_slots / HEAP_OBJ_LIMIT;
if (!add) {
if (add < 1) {
add = 1;
}
......
for (i = 0; i < add; i++) {
assign_heap_slot(objspace);
}
}
static void
init_heap(rb_objspace_t *objspace)
{
int add;
add = HEAP_MIN_SLOTS / HEAP_OBJ_LIMIT;
add_heap_slots(objspace, add);
heaps_inc = 0;
objspace->profile.invoke_time = getrusage_time();
finalizer_table = st_init_numtable();
}
static void
initial_expand_heap(rb_objspace_t *objspace)
{
int add;
add = ((initial_heap_min_slots / HEAP_OBJ_LIMIT) - heaps_used);
if (add > 0) {
add_heap_slots(objspace, add);
}
}
static void
set_heaps_increment(rb_objspace_t *objspace)
{
size_t next_heaps_length = (size_t)(heaps_used * 1.8);
......
init_heap(&rb_objspace);
}
static VALUE
lazy_sweep_enable(void)
{
    (1-1/1)