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

ruby-changes:32208

From: ko1 <ko1@a...>
Date: Thu, 19 Dec 2013 14:05:07 +0900 (JST)
Subject: [ruby-changes:32208] ko1:r44287 (trunk): * gc.c (heap_get_freeobj): improve hot path performance.

ko1	2013-12-19 14:04:55 +0900 (Thu, 19 Dec 2013)

  New Revision: 44287

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

  Log:
    * gc.c (heap_get_freeobj): improve hot path performance.
    * gc.c (heap_get_freeobj_from_next_freepage): replace with
      heap_get_freepage(). It returns freeobj instead of freepage.
      This is not on hot path.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44286)
+++ ChangeLog	(revision 44287)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Dec 19 14:03:04 2013  Koichi Sasada  <ko1@a...>
+
+	* gc.c (heap_get_freeobj): improve hot path performance.
+
+	* gc.c (heap_get_freeobj_from_next_freepage): replace with
+	  heap_get_freepage(). It returns freeobj instead of freepage.
+	  This is not on hot path.
+
 Thu Dec 19 12:05:17 2013  Eric Hodel  <drbrain@s...>
 
 	* lib/rubygems:  Update to RubyGems master af60443.  Changes include:
Index: gc.c
===================================================================
--- gc.c	(revision 44286)
+++ gc.c	(revision 44287)
@@ -1218,18 +1218,23 @@ heap_prepare_freepage(rb_objspace_t *obj https://github.com/ruby/ruby/blob/trunk/gc.c#L1218
     return heap->free_pages;
 }
 
-static inline struct heap_page *
-heap_get_freepage(rb_objspace_t *objspace, rb_heap_t *heap)
+static RVALUE *
+heap_get_freeobj_from_next_freepage(rb_objspace_t *objspace, rb_heap_t *heap)
 {
     struct heap_page *page;
+    RVALUE *p;
 
     page = heap->free_pages;
     while (page == NULL) {
 	page = heap_prepare_freepage(objspace, heap);
     }
     heap->free_pages = page->free_next;
+    heap->using_page = page;
 
-    return page;
+    p = page->freelist;
+    page->freelist = NULL;
+
+    return p;
 }
 
 static inline VALUE
@@ -1237,15 +1242,15 @@ heap_get_freeobj(rb_objspace_t *objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L1242
 {
     RVALUE *p = heap->freelist;
 
-    while (UNLIKELY(p == NULL)) {
-	struct heap_page *page = heap_get_freepage(objspace, heap);
-	heap->using_page = page;
-	p = page->freelist;
-	page->freelist = NULL;
+    while (1) {
+	if (p) {
+	    heap->freelist = p->as.free.next;
+	    return (VALUE)p;
+	}
+	else {
+	    p = heap_get_freeobj_from_next_freepage(objspace, heap);
+	}
     }
-    heap->freelist = p->as.free.next;
-
-    return (VALUE)p;
 }
 
 void

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

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