Bug #9225

[patch] add WB to NODE_CREF

Added by Aman Gupta over 1 year ago. Updated over 1 year ago.

[ruby-core:58947]
Status:Closed
Priority:Normal
Assignee:Koichi Sasada
ruby -v:trunk Backport:1.9.3: UNKNOWN, 2.0.0: UNKNOWN

Description

In our rails app, there are a lot of long-lived NODE_CREF:

p ObjectSpace.count_nodes
=> {:NODE_IF=>3, :NODE_CREF=>45810, :NODE_IFUNC=>11}

These are static objects, but are considered SHADY and contribute to the size of the remembered set:

GC.stat[:remembered_shady_object]
=> 49667

With the following patch, NODE_CREF are no longer shady and can be promoted: https://github.com/tmm1/ruby/commit/c5e8341

This reduces the size of the remembered set in our app, and speeds up minor GC from 22ms to 18ms per run.
After the patch:

GC.stat[:remembered_shady_object]
=> 10506

The patch is passing make test-all with RGENGC_CHECK=2

Associated revisions

Revision 44059
Added by Aman Gupta over 1 year ago

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]
  • 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

Revision 44059
Added by Aman Gupta over 1 year ago

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]
  • 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

History

#1 Updated by Aman Gupta over 1 year ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r44059.
Aman, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


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]
  • 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

Also available in: Atom PDF