ruby-changes:31980
From: tmm1 <ko1@a...>
Date: Sun, 8 Dec 2013 11:28:27 +0900 (JST)
Subject: [ruby-changes:31980] tmm1:r44059 (trunk): gc.c: promote long-lived NODE_CREF objects to oldgen
tmm1 2013-12-08 11:28:04 +0900 (Sun, 08 Dec 2013) New Revision: 44059 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44059 Log: gc.c: promote long-lived NODE_CREF objects to oldgen * include/ruby/ruby.h: add RGENGC_WB_PROTECTED_NODE_CREF setting In a large app, this reduces the size of remembered_shady_object_count by 80%. [Bug #9225] [ruby-core:58947] * gc.c (rb_node_newnode): add FL_WB_PROTECTED flag to NODE_CREF * class.c (rewrite_cref_stack): insert OBJ_WRITE for NODE_CREF * iseq.c (set_relation): ditto * iseq.c (rb_iseq_clone): ditto * vm_eval.c (rb_yield_refine_block): ditto * vm_insnhelper.c (vm_cref_push): ditto * vm_insnhelper.h (COPY_CREF): ditto Modified files: trunk/ChangeLog trunk/class.c trunk/gc.c trunk/include/ruby/ruby.h trunk/iseq.c trunk/vm_eval.c trunk/vm_insnhelper.c trunk/vm_insnhelper.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 44058) +++ include/ruby/ruby.h (revision 44059) @@ -740,6 +740,9 @@ VALUE rb_obj_setup(VALUE obj, VALUE klas https://github.com/ruby/ruby/blob/trunk/include/ruby/ruby.h#L740 #ifndef RGENGC_WB_PROTECTED_BIGNUM #define RGENGC_WB_PROTECTED_BIGNUM 1 #endif +#ifndef RGENGC_WB_PROTECTED_NODE_CREF +#define RGENGC_WB_PROTECTED_NODE_CREF 1 +#endif struct RBasic { VALUE flags; Index: ChangeLog =================================================================== --- ChangeLog (revision 44058) +++ ChangeLog (revision 44059) @@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Dec 8 11:21:00 2013 Aman Gupta <ruby@t...> + + * include/ruby/ruby.h: add RGENGC_WB_PROTECTED_NODE_CREF setting + In a large app, this reduces the size of + remembered_shady_object_count by 80%. [Bug #9225] [ruby-core:58947] + * gc.c (rb_node_newnode): add FL_WB_PROTECTED flag to NODE_CREF + * class.c (rewrite_cref_stack): insert OBJ_WRITE for NODE_CREF + * iseq.c (set_relation): ditto + * iseq.c (rb_iseq_clone): ditto + * vm_eval.c (rb_yield_refine_block): ditto + * vm_insnhelper.c (vm_cref_push): ditto + * vm_insnhelper.h (COPY_CREF): ditto + Sun Dec 8 10:45:05 2013 Aman Gupta <ruby@t...> * hash.c (hash_aset_str): revert r43870 due to performance issue Index: iseq.c =================================================================== --- iseq.c (revision 44058) +++ iseq.c (revision 44059) @@ -215,7 +215,7 @@ set_relation(rb_iseq_t *iseq, const VALU https://github.com/ruby/ruby/blob/trunk/iseq.c#L215 NODE *cref = NEW_CREF(th->top_wrapper); cref->nd_refinements = Qnil; cref->nd_visi = NOEX_PRIVATE; - cref->nd_next = iseq->cref_stack; + OBJ_WRITE(cref, &cref->nd_next, iseq->cref_stack); ISEQ_SET_CREF(iseq, cref); } iseq->local_iseq = iseq; @@ -1930,10 +1930,10 @@ rb_iseq_clone(VALUE iseqval, VALUE newcb https://github.com/ruby/ruby/blob/trunk/iseq.c#L1930 } if (newcbase) { ISEQ_SET_CREF(iseq1, NEW_CREF(newcbase)); - iseq1->cref_stack->nd_refinements = iseq0->cref_stack->nd_refinements; + OBJ_WRITE(iseq1->cref_stack, &iseq1->cref_stack->nd_refinements, iseq0->cref_stack->nd_refinements); iseq1->cref_stack->nd_visi = iseq0->cref_stack->nd_visi; if (iseq0->cref_stack->nd_next) { - iseq1->cref_stack->nd_next = iseq0->cref_stack->nd_next; + OBJ_WRITE(iseq1->cref_stack, &iseq1->cref_stack->nd_next, iseq0->cref_stack->nd_next); } OBJ_WRITE(iseq1, &iseq1->klass, newcbase); } Index: vm_eval.c =================================================================== --- vm_eval.c (revision 44058) +++ vm_eval.c (revision 44059) @@ -1546,7 +1546,7 @@ rb_yield_refine_block(VALUE refinement, https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1546 } cref = vm_cref_push(th, refinement, NOEX_PUBLIC, blockptr); cref->flags |= NODE_FL_CREF_PUSHED_BY_EVAL; - cref->nd_refinements = refinements; + OBJ_WRITE(cref, &cref->nd_refinements, refinements); return vm_yield_with_cref(th, 0, NULL, cref); } Index: gc.c =================================================================== --- gc.c (revision 44058) +++ gc.c (revision 44059) @@ -1344,7 +1344,8 @@ rb_newobj_of(VALUE klass, VALUE flags) https://github.com/ruby/ruby/blob/trunk/gc.c#L1344 NODE* rb_node_newnode(enum node_type type, VALUE a0, VALUE a1, VALUE a2) { - NODE *n = (NODE *)newobj_of(0, T_NODE, a0, a1, a2); + VALUE flags = (RGENGC_WB_PROTECTED_NODE_CREF && type == NODE_CREF ? FL_WB_PROTECTED : 0); + NODE *n = (NODE *)newobj_of(0, T_NODE | flags, a0, a1, a2); nd_set_type(n, type); return n; } Index: class.c =================================================================== --- class.c (revision 44058) +++ class.c (revision 44059) @@ -239,7 +239,7 @@ rewrite_cref_stack(NODE *node, VALUE old https://github.com/ruby/ruby/blob/trunk/class.c#L239 while (node) { if (node->nd_clss == old_klass) { new_node = NEW_CREF(new_klass); - new_node->nd_next = node->nd_next; + OBJ_WRITE(new_node, &new_node->nd_next, node->nd_next); *new_cref_ptr = new_node; return; } Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 44058) +++ vm_insnhelper.c (revision 44059) @@ -285,10 +285,10 @@ vm_cref_push(rb_thread_t *th, VALUE klas https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L285 cref->nd_visi = noex; if (blockptr) { - cref->nd_next = vm_get_cref0(blockptr->iseq, blockptr->ep); + OBJ_WRITE(cref, &cref->nd_next, vm_get_cref0(blockptr->iseq, blockptr->ep)); } else if (cfp) { - cref->nd_next = vm_get_cref0(cfp->iseq, cfp->ep); + OBJ_WRITE(cref, &cref->nd_next, vm_get_cref0(cfp->iseq, cfp->ep)); } /* TODO: why cref->nd_next is 1? */ if (cref->nd_next && cref->nd_next != (void *) 1 && Index: vm_insnhelper.h =================================================================== --- vm_insnhelper.h (revision 44058) +++ vm_insnhelper.h (revision 44059) @@ -174,7 +174,7 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L174 /**********************************************************/ #define COPY_CREF_OMOD(c1, c2) do { \ - (c1)->nd_refinements = (c2)->nd_refinements; \ + OBJ_WRITE((c1), &(c1)->nd_refinements, (c2)->nd_refinements); \ if (!NIL_P((c2)->nd_refinements)) { \ (c1)->flags |= NODE_FL_CREF_OMOD_SHARED; \ (c2)->flags |= NODE_FL_CREF_OMOD_SHARED; \ @@ -184,9 +184,9 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L184 #define COPY_CREF(c1, c2) do { \ NODE *__tmp_c2 = (c2); \ COPY_CREF_OMOD(c1, __tmp_c2); \ - (c1)->nd_clss = __tmp_c2->nd_clss; \ + OBJ_WRITE((c1), &(c1)->nd_clss, __tmp_c2->nd_clss); \ (c1)->nd_visi = __tmp_c2->nd_visi;\ - (c1)->nd_next = __tmp_c2->nd_next; \ + OBJ_WRITE((c1), &(c1)->nd_next, __tmp_c2->nd_next); \ if (__tmp_c2->flags & NODE_FL_CREF_PUSHED_BY_EVAL) { \ (c1)->flags |= NODE_FL_CREF_PUSHED_BY_EVAL; \ } \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/