ruby-changes:31895
From: tmm1 <ko1@a...>
Date: Tue, 3 Dec 2013 17:13:36 +0900 (JST)
Subject: [ruby-changes:31895] tmm1:r43974 (trunk): * load.c (features_index_add_single): Move loaded_features_index array values off
tmm1 2013-12-03 17:13:31 +0900 (Tue, 03 Dec 2013) New Revision: 43974 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43974 Log: * load.c (features_index_add_single): Move loaded_features_index array values off the ruby heap. [Bug #9201] [ruby-core:58805] * load.c (loaded_features_index_clear_i): Clean up off-heap array structure. * vm.c (rb_vm_mark): Remove unnecessary mark_tbl for loaded_features_index. This improves minor GC time by 15% in a large application. Modified files: trunk/ChangeLog trunk/load.c trunk/vm.c Index: ChangeLog =================================================================== --- ChangeLog (revision 43973) +++ ChangeLog (revision 43974) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Dec 3 17:11:47 2013 Aman Gupta <ruby@t...> + + * load.c (features_index_add_single): Move loaded_features_index array values off + the ruby heap. [Bug #9201] [ruby-core:58805] + * load.c (loaded_features_index_clear_i): Clean up off-heap array structure. + * vm.c (rb_vm_mark): Remove unnecessary mark_tbl for loaded_features_index. + This improves minor GC time by 15% in a large application. + Tue Dec 3 17:01:45 2013 Aman Gupta <ruby@t...> * include/ruby/ruby.h (struct RClass): Add wrapper struct around Index: load.c =================================================================== --- load.c (revision 43973) +++ load.c (revision 43974) @@ -203,7 +203,8 @@ features_index_add_single(VALUE short_fe https://github.com/ruby/ruby/blob/trunk/load.c#L203 VALUE feature_indexes[2]; feature_indexes[0] = this_feature_index; feature_indexes[1] = offset; - this_feature_index = rb_ary_tmp_new(numberof(feature_indexes)); + this_feature_index = (VALUE)xcalloc(1, sizeof(struct RArray)); + RBASIC(this_feature_index)->flags = T_ARRAY; /* fake VALUE, do not mark/sweep */ rb_ary_cat(this_feature_index, feature_indexes, numberof(feature_indexes)); st_insert(features_index, (st_data_t)short_feature_cstr, (st_data_t)this_feature_index); } @@ -263,6 +264,11 @@ features_index_add(VALUE feature, VALUE https://github.com/ruby/ruby/blob/trunk/load.c#L264 static int loaded_features_index_clear_i(st_data_t key, st_data_t val, st_data_t arg) { + VALUE obj = (VALUE)val; + if (!SPECIAL_CONST_P(obj)) { + rb_ary_free(obj); + xfree((void *)obj); + } xfree((char *)key); return ST_DELETE; } Index: vm.c =================================================================== --- vm.c (revision 43973) +++ vm.c (revision 43974) @@ -1612,9 +1612,6 @@ rb_vm_mark(void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L1612 if (vm->loading_table) { rb_mark_tbl(vm->loading_table); } - if (vm->loaded_features_index) { - rb_mark_tbl(vm->loaded_features_index); - } rb_vm_trace_mark_event_hooks(&vm->event_hooks); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/