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

ruby-changes:33103

From: ko1 <ko1@a...>
Date: Wed, 26 Feb 2014 18:46:52 +0900 (JST)
Subject: [ruby-changes:33103] ko1:r45182 (trunk): * gc.c (heap_pages_free_unused_pages): check tomb page availability

ko1	2014-02-26 18:46:45 +0900 (Wed, 26 Feb 2014)

  New Revision: 45182

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

  Log:
    * gc.c (heap_pages_free_unused_pages): check tomb page availability
      at first.
      And return immediately if we don't touch sorted list any more.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45181)
+++ ChangeLog	(revision 45182)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Feb 26 18:43:43 2014  Koichi Sasada  <ko1@a...>
+
+	* gc.c (heap_pages_free_unused_pages): check tomb page availability
+	  at first.
+	  And return immediately if we don't touch sorted list any more.
+
 Wed Feb 26 14:10:44 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* eval.c (setup_exception): preserve exception class name encoding
Index: gc.c
===================================================================
--- gc.c	(revision 45181)
+++ gc.c	(revision 45182)
@@ -999,28 +999,30 @@ heap_pages_free_unused_pages(rb_objspace https://github.com/ruby/ruby/blob/trunk/gc.c#L999
 {
     size_t i, j;
 
-    for (i = j = 1; j < heap_pages_used; i++) {
-	struct heap_page *page = heap_pages_sorted[i];
+    if (heap_tomb->pages) {
+	for (i = j = 1; j < heap_pages_used; i++) {
+	    struct heap_page *page = heap_pages_sorted[i];
 
-	if (page->heap == heap_tomb && page->final_slots == 0) {
-	    if (heap_pages_swept_slots - page->limit > heap_pages_max_free_slots) {
-		if (0) fprintf(stderr, "heap_pages_free_unused_pages: %d free page %p, heap_pages_swept_slots: %d, heap_pages_max_free_slots: %d\n",
-			       (int)i, page, (int)heap_pages_swept_slots, (int)heap_pages_max_free_slots);
-		heap_pages_swept_slots -= page->limit;
-		heap_unlink_page(objspace, heap_tomb, page);
-		heap_page_free(objspace, page);
-		continue;
+	    if (page->heap == heap_tomb && page->final_slots == 0) {
+		if (heap_pages_swept_slots - page->limit > heap_pages_max_free_slots) {
+		    if (0) fprintf(stderr, "heap_pages_free_unused_pages: %d free page %p, heap_pages_swept_slots: %d, heap_pages_max_free_slots: %d\n",
+				   (int)i, page, (int)heap_pages_swept_slots, (int)heap_pages_max_free_slots);
+		    heap_pages_swept_slots -= page->limit;
+		    heap_unlink_page(objspace, heap_tomb, page);
+		    heap_page_free(objspace, page);
+		    continue;
+		}
+		else if (i == j) {
+		    return; /* no need to check rest pages */
+		}
 	    }
-	    else {
-		/* fprintf(stderr, "heap_pages_free_unused_pages: remain!!\n"); */
+	    if (i != j) {
+		heap_pages_sorted[j] = page;
 	    }
+	    j++;
 	}
-	if (i != j) {
-	    heap_pages_sorted[j] = page;
-	}
-	j++;
+	assert(j == heap_pages_used);
     }
-    assert(j == heap_pages_used);
 }
 
 static struct heap_page *

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

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