[MacRuby] #1303: GC does not actively work with RubySpec after "core/gc".
#1303: GC does not actively work with RubySpec after "core/gc". ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- When I executed the RubySpec, I displayed log of GC. {{{ $ GC_DEBUG=t opts="--verbose" rake spec:rubyspec ---- snip ---- /Users/watson/src/macruby-trunk/spec/frozen/core/float/rationalize_spec.rb macruby(25905,0x108281000) malloc: auto malloc[25905]: full GC collected 9232 objects (595904 bytes) (107281312 bytes in use) 50292 usec (42432 + 6112 + 453 + 1295 [scan + freeze + finalize + reclaim]) . /Users/watson/src/macruby-trunk/spec/frozen/core/float/round_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/float/to_f_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/float/to_i_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/float/to_int_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/float/to_r_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/float/to_s_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/float/truncate_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/float/uminus_spec.rb macruby(25905,0x108281000) malloc: auto malloc[25905]: gen. GC collected 11446 objects (736224 bytes) (107510720 bytes in use) 16803 usec (9232 + 5393 + 548 + 1630 [scan + freeze + finalize + reclaim]) . /Users/watson/src/macruby-trunk/spec/frozen/core/float/uplus_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/float/zero_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/gc/count_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/gc/disable_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/gc/enable_spec.rb . /Users/watson/src/macruby- trunk/spec/frozen/core/gc/garbage_collect_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/gc/profiler/clear_spec.rb . /Users/watson/src/macruby- trunk/spec/frozen/core/gc/profiler/disable_spec.rb . /Users/watson/src/macruby- trunk/spec/frozen/core/gc/profiler/enable_spec.rb . /Users/watson/src/macruby- trunk/spec/frozen/core/gc/profiler/enabled_spec.rb . /Users/watson/src/macruby- trunk/spec/frozen/core/gc/profiler/report_spec.rb . /Users/watson/src/macruby- trunk/spec/frozen/core/gc/profiler/result_spec.rb . /Users/watson/src/macruby- trunk/spec/frozen/core/gc/profiler/total_time_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/gc/start_spec.rb . /Users/watson/src/macruby-trunk/spec/frozen/core/gc/stress_spec.rb . ---- snip ---- }}} It seems that the frequency that log of GC is displayed falls. It looks like that does not almost work. When I executed the RubySpec without "core/gc", the log of GC was displayed frequently. {{{ #!diff diff --git a/spec/macruby.mspec b/spec/macruby.mspec index 0d24aa4..5afa9d0 100644 --- a/spec/macruby.mspec +++ b/spec/macruby.mspec @@ -11,6 +11,7 @@ class MSpecScript # Core library specs set :core, [ 'core', + '^core/gc', # obsolete in 1.9 '^core/continuation', }}} Before a changing, MacRuby used the memory of 1.12GB. After, used 612MB. But, RubySpec crashes frequently by above changing. -- Ticket URL: <http://www.macruby.org/trac/ticket/1303> MacRuby <http://macruby.org/>
#1303: GC does not actively work with RubySpec after "core/gc". ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by watson1978@…): I think MacRuby needs some GC_WB. {{{ #!diff diff --git a/dispatcher.cpp b/dispatcher.cpp index b04f1e8..7fbbb22 100644 --- a/dispatcher.cpp +++ b/dispatcher.cpp @@ -1084,7 +1084,7 @@ dup_block(rb_vm_block_t *src_b) while (src_l != NULL) { GC_WB(new_l, xmalloc(sizeof(rb_vm_local_t))); (*new_l)->name = src_l->name; - (*new_l)->value = src_l->value; + GC_WB(&(*new_l)->value, src_l->value); new_l = &(*new_l)->next; src_l = src_l->next; @@ -1318,7 +1318,7 @@ rb_vm_yield_under(VALUE klass, VALUE self, int argc, const VALUE *argv) vm->pop_current_block(); VALUE old_self = b->self; - b->self = self; + GC_WB(&b->self, self); VALUE old_class = b->klass; b->klass = klass; GC_WB(&b->outer, vm->create_outer((Class)klass, b->outer, true)); @@ -1337,7 +1337,7 @@ rb_vm_yield_under(VALUE klass, VALUE self, int argc, const VALUE *argv) } ~Finally() { GC_WB(&b->outer, b->outer->outer); - b->self = old_self; + GC_WB(&b->self, old_self); b->klass = old_class; vm->add_current_block(b); } @@ -1418,13 +1418,13 @@ rb_vm_prepare_block(void *function, int flags, VALUE self, rb_vm_arity_t arity, GET_CORE()->unlock(); #endif } - b->userdata = (VALUE)function; + GC_WB(&b->userdata, (VALUE)function); } b->arity = arity; b->flags = flags; b->dvars_size = dvars_size; b->parent_var_uses = NULL; - b->parent_block = NULL; + GC_WB(&b->parent_block, NULL); } else { assert(b->dvars_size == dvars_size); @@ -1456,7 +1456,7 @@ rb_vm_prepare_block(void *function, int flags, VALUE self, rb_vm_arity_t arity, for (int i = 0; i < lvars_size; ++i) { assert(l != NULL); l->name = va_arg(ar, ID); - l->value = va_arg(ar, VALUE *); + GC_WB(&l->value, va_arg(ar, VALUE *)); l = l->next; } } diff --git a/vm.cpp b/vm.cpp index ffcb22d..3a64a82 100644 --- a/vm.cpp +++ b/vm.cpp @@ -3332,7 +3332,7 @@ rb_vm_keep_vars(rb_vm_var_uses *uses, int lvars_size, ...) } // the parent pointers can't be used anymore - block->parent_block = NULL; + GC_WB(&block->parent_block, NULL); block->parent_var_uses = NULL; locals_to_replace = block->locals; @@ -3363,7 +3363,7 @@ push_local(rb_vm_local_t **l, ID name, VALUE *value) { GC_WB(l, xmalloc(sizeof(rb_vm_local_t))); (*l)->name = name; - (*l)->value = value; + GC_WB(&(*l)->value, value); (*l)->next = NULL; return &(*l)->next; } @@ -3498,7 +3498,7 @@ rb_vm_create_block_from_method(rb_vm_method_t *method) b->flags = VM_BLOCK_PROC | VM_BLOCK_METHOD; b->locals = NULL; b->parent_var_uses = NULL; - b->parent_block = NULL; + GC_WB(&b->parent_block, NULL); b->dvars_size = 0; return b; }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1303#comment:1> MacRuby <http://macruby.org/>
#1303: GC does not actively work with RubySpec after "core/gc". ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): These GC_WB are not the reason why the GC stops working during rubyspec. A missing GC_WB would lead to a premature garbage collection then a crash. I suspect one of the GC specs actually disable the collector and forget to re-enable it. -- Ticket URL: <http://www.macruby.org/trac/ticket/1303#comment:2> MacRuby <http://macruby.org/>
#1303: GC does not actively work with RubySpec after "core/gc". ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: critical | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): The following change seems to make the GC work during rubyspec: {{{ diff --git a/spec/frozen/core/gc/disable_spec.rb b/spec/frozen/core/gc/disable_spec.rb index c28c57a..82dbd65 100644 --- a/spec/frozen/core/gc/disable_spec.rb +++ b/spec/frozen/core/gc/disable_spec.rb @@ -12,6 +12,7 @@ describe "GC.disable" do GC.enable GC.disable.should == false GC.disable.should == true + GC.enable end end }}} I think that the after block in the spec is never called. -- Ticket URL: <http://www.macruby.org/trac/ticket/1303#comment:3> MacRuby <http://macruby.org/>
#1303: GC does not actively work with RubySpec after "core/gc". ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: critical | Milestone: MacRuby 0.11 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.11 Comment: Closing this ticket as my stomach is too weak for me to look at the mspec code. Watson: some of these GC_WB are valid, some are not. There is no need to use a WB when setting NULL for instance (unless there is a previous value and you want to tell the collector). Similarly, WB should only be used when setting xmalloc() memory. -- Ticket URL: <http://www.macruby.org/trac/ticket/1303#comment:4> MacRuby <http://macruby.org/>
#1303: GC does not actively work with RubySpec after "core/gc". ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: critical | Milestone: MacRuby 0.11 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------+----------------------------------------- Comment(by watson1978@…): Thank you for your comment. I have a question. [[br]] GC_WB() was used with NULL in https://github.com/MacRuby/MacRuby/commit/fc9244dcf5f4ff299a80b3a251cc3226b5... [[br]] Question : Is GC_WB unnecessary in https://github.com/MacRuby/MacRuby/commit/fc9244dcf5f4ff299a80b3a251cc3226b5... -- Ticket URL: <http://www.macruby.org/trac/ticket/1303#comment:5> MacRuby <http://macruby.org/>
#1303: GC does not actively work with RubySpec after "core/gc". ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: critical | Milestone: MacRuby 0.11 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------+----------------------------------------- Comment(by lsansonetti@…): Indeed it's not necessary, but I like to have GC_WB here for code consistency / readability. As GC_WB() is a macro, and as NULL/0 is a special constant, the compiler will optimize the call to a simple assignment. -- Ticket URL: <http://www.macruby.org/trac/ticket/1303#comment:6> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby