ruby-changes:29043
From: tarui <ko1@a...>
Date: Thu, 6 Jun 2013 00:57:21 +0900 (JST)
Subject: [ruby-changes:29043] tarui:r41095 (trunk): * gc.c (rgengc_rememberset_mark): change scan algorithm for performance:
tarui 2013-06-06 00:57:12 +0900 (Thu, 06 Jun 2013) New Revision: 41095 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41095 Log: * gc.c (rgengc_rememberset_mark): change scan algorithm for performance: from object's pointer base to bitmap one. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41094) +++ ChangeLog (revision 41095) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Jun 6 00:52:42 2013 Masaya Tarui <tarui@r...> + + * gc.c (rgengc_rememberset_mark): change scan algorithm for performance: + from object's pointer base to bitmap one. + Thu Jun 6 00:30:04 2013 NARUSE, Yui <naruse@r...> * win32/win32.c (NET_LUID): define it on MinGW32. Index: gc.c =================================================================== --- gc.c (revision 41094) +++ gc.c (revision 41095) @@ -3591,33 +3591,38 @@ rgengc_remembered(rb_objspace_t *objspac https://github.com/ruby/ruby/blob/trunk/gc.c#L3591 static size_t rgengc_rememberset_mark(rb_objspace_t *objspace) { - size_t i; + size_t i, j; size_t shady_object_count = 0; - RVALUE *p, *pend; - uintptr_t *bits; + RVALUE *p, *offset; + uintptr_t *bits, bitset; for (i=0; i<heaps_used; i++) { - if (0 /* TODO: optimization - skip it if there are no remembered objects */) { - continue; - } - - p = objspace->heap.sorted[i]->start; pend = p + objspace->heap.sorted[i]->limit; + p = objspace->heap.sorted[i]->start; bits = GET_HEAP_REMEMBERSET_BITS(p); - while (p < pend) { - if (MARKED_IN_BITMAP(bits, p)) { - gc_mark(objspace, (VALUE)p); - rgengc_report(2, objspace, "rgengc_rememberset_mark: mark %p (%s)\n", p, obj_type_name((VALUE)p)); + offset = p - NUM_IN_SLOT(p); - if (RVALUE_SUNNY(p)) { - rgengc_report(2, objspace, "rgengc_rememberset_mark: clear %p (%s)\n", p, obj_type_name((VALUE)p)); - CLEAR_IN_BITMAP(bits, p); - } - else { - shady_object_count++; + for(j=0;j< HEAP_BITMAP_LIMIT;j++){ + if(bits[j]){ + p = offset + j * (sizeof(uintptr_t) * CHAR_BIT); + bitset = bits[j]; + while (bitset) { + if (bitset & 1) { + gc_mark(objspace, (VALUE)p); + rgengc_report(2, objspace, "rgengc_rememberset_mark: mark %p (%s)\n", p, obj_type_name((VALUE)p)); + + if (RVALUE_SUNNY(p)) { + rgengc_report(2, objspace, "rgengc_rememberset_mark: clear %p (%s)\n", p, obj_type_name((VALUE)p)); + CLEAR_IN_BITMAP(bits, p); + } + else { + shady_object_count++; + } + } + p++; + bitset>>=1; } } - p++; } } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/