[前][次][番号順一覧][スレッド一覧]

ruby-changes:29408

From: tarui <ko1@a...>
Date: Thu, 20 Jun 2013 07:48:12 +0900 (JST)
Subject: [ruby-changes:29408] tarui:r41460 (trunk): * gc.c (rb_gc_writebarrier): give up rescan A and register B directly

tarui	2013-06-20 07:48:03 +0900 (Thu, 20 Jun 2013)

  New Revision: 41460

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41460

  Log:
    * gc.c (rb_gc_writebarrier): give up rescan A and register B directly
      if A has huge number of children.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41459)
+++ ChangeLog	(revision 41460)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Jun 20 07:46:48 2013  Masaya Tarui  <tarui@r...>
+
+	* gc.c (rb_gc_writebarrier): give up rescan A and register B directly
+	  if A has huge number of children.
+
 Thu Jun 20 07:30:35 2013  Koichi Sasada  <ko1@a...>
 
 	* common.mk: add new rules `gcbench-rdoc', `gcbench-hash'.
Index: gc.c
===================================================================
--- gc.c	(revision 41459)
+++ gc.c	(revision 41460)
@@ -3786,6 +3786,7 @@ void https://github.com/ruby/ruby/blob/trunk/gc.c#L3786
 rb_gc_writebarrier(VALUE a, VALUE b)
 {
     rb_objspace_t *objspace = &rb_objspace;
+    int type;
 
     if (RGENGC_CHECK_MODE) {
 	if (!RVALUE_PROMOTED(a)) rb_bug("rb_gc_wb: referer object %p (%s) is not promoted.\n", (void *)a, obj_type_name(a));
@@ -3793,9 +3794,21 @@ rb_gc_writebarrier(VALUE a, VALUE b) https://github.com/ruby/ruby/blob/trunk/gc.c#L3794
     }
 
     if (!rgengc_remembered(objspace, a)) {
-	rgengc_report(2, objspace, "rb_gc_wb: %p (%s) -> %p (%s)\n",
-		      (void *)a, obj_type_name(a), (void *)b, obj_type_name(b));
-	rgengc_remember(objspace, a);
+        type = BUILTIN_TYPE(a);
+        /* TODO: 2 << 16 is just a magic number. */
+        if ((type == T_ARRAY && RARRAY_LEN(a) >= 2 << 16) ||
+            (type == T_HASH  && RHASH_SIZE(a) >= 2 << 16)) {
+            if (!rgengc_remembered(objspace, b)) {
+                rgengc_report(2, objspace, "rb_gc_wb: %p (%s) -> %p (%s)\n",
+                              (void *)a, obj_type_name(a), (void *)b, obj_type_name(b));
+                rgengc_remember(objspace, b);
+            }
+        }
+        else {
+            rgengc_report(2, objspace, "rb_gc_wb: %p (%s) -> %p (%s)\n",
+                          (void *)a, obj_type_name(a), (void *)b, obj_type_name(b));
+            rgengc_remember(objspace, a);
+        }
     }
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]