diff --git a/ChangeLog b/ChangeLog index 14958852b0..c650cb368e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Thu Dec 5 09:07:59 2013 Aman Gupta + + * gc.c (ruby_gc_set_params): Accept safe_level argument so GC tuning + settings can be applied before rb_safe_level() is available. + * internal.h (rb_gc_set_params): ditto. + * ruby.c (process_options): Apply GC tuning early during boot process + so boot-time allocations can benefit. This also benefits any code + loaded in via `ruby -r`. + Wed Dec 4 13:02:13 2013 Aman Gupta * vm_trace.c (rb_suppress_tracing): Fix initialization of stack diff --git a/gc.c b/gc.c index ddf607ce20..aff7b118ac 100644 --- a/gc.c +++ b/gc.c @@ -5386,9 +5386,9 @@ gc_set_initial_pages(void) */ void -ruby_gc_set_params(void) +ruby_gc_set_params(int safe_level) { - if (rb_safe_level() > 0) return; + if (safe_level > 0) return; /* RUBY_GC_HEAP_FREE_SLOTS */ if (get_envparam_int ("RUBY_FREE_MIN", &gc_params.heap_free_slots, 0)) { @@ -5419,7 +5419,7 @@ ruby_gc_set_params(void) #endif } -RUBY_ALIAS_FUNCTION_VOID(rb_gc_set_params(void), ruby_gc_set_params, ()) +RUBY_ALIAS_FUNCTION_VOID(rb_gc_set_params(void), ruby_gc_set_params, (rb_safe_level())) void rb_objspace_reachable_objects_from(VALUE obj, void (func)(VALUE, void *), void *data) diff --git a/internal.h b/internal.h index 0e47e8db0a..0c9427b202 100644 --- a/internal.h +++ b/internal.h @@ -453,7 +453,7 @@ void *ruby_mimmalloc(size_t size); void ruby_mimfree(void *ptr); void rb_objspace_set_event_hook(const rb_event_flag_t event); void rb_gc_writebarrier_remember_promoted(VALUE obj); -void ruby_gc_set_params(void); +void ruby_gc_set_params(int safe_level); #if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32) #define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size) diff --git a/ruby.c b/ruby.c index 034425e296..a871242272 100644 --- a/ruby.c +++ b/ruby.c @@ -1405,6 +1405,7 @@ process_options(int argc, char **argv, struct cmdline_options *opt) translit_char(RSTRING_PTR(opt->script_name), '\\', '/'); #endif + ruby_gc_set_params(opt->safe_level); ruby_init_loadpath_safe(opt->safe_level); Init_enc(); rb_enc_find_index("encdb"); @@ -1568,7 +1569,6 @@ process_options(int argc, char **argv, struct cmdline_options *opt) rb_define_readonly_boolean("$-a", opt->do_split); rb_set_safe_level(opt->safe_level); - ruby_gc_set_params(); return iseq; }