[pypy-commit] pypy default: Print some more stats at the end of a major GC

arigo pypy.commits at gmail.com
Tue Jan 9 17:45:29 EST 2018


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r93642:e21bb2a19d05
Date: 2018-01-09 23:44 +0100
http://bitbucket.org/pypy/pypy/changeset/e21bb2a19d05/

Log:	Print some more stats at the end of a major GC

diff --git a/rpython/memory/gc/incminimark.py b/rpython/memory/gc/incminimark.py
--- a/rpython/memory/gc/incminimark.py
+++ b/rpython/memory/gc/incminimark.py
@@ -2354,6 +2354,8 @@
                 if self.rrc_enabled:
                     self.rrc_major_collection_free()
                 #
+                self.stat_ac_arenas_count = self.ac.arenas_count
+                self.stat_rawmalloced_total_size = self.rawmalloced_total_size
                 self.gc_state = STATE_SWEEPING
             #END MARKING
         elif self.gc_state == STATE_SWEEPING:
@@ -2383,6 +2385,18 @@
                 # We also need to reset the GCFLAG_VISITED on prebuilt GC objects.
                 self.prebuilt_root_objects.foreach(self._reset_gcflag_visited, None)
                 #
+                # Print statistics
+                debug_start("gc-collect-done")
+                debug_print("arenas:               ",
+                            self.stat_ac_arenas_count, " => ",
+                            self.ac.arenas_count)
+                debug_print("bytes used in arenas: ",
+                            self.ac.total_memory_used)
+                debug_print("bytes raw-malloced:   ",
+                            self.stat_rawmalloced_total_size, " => ",
+                            self.rawmalloced_total_size)
+                debug_stop("gc-collect-done")
+                #
                 # Set the threshold for the next major collection to be when we
                 # have allocated 'major_collection_threshold' times more than
                 # we currently have -- but no more than 'max_delta' more than
diff --git a/rpython/memory/gc/minimarkpage.py b/rpython/memory/gc/minimarkpage.py
--- a/rpython/memory/gc/minimarkpage.py
+++ b/rpython/memory/gc/minimarkpage.py
@@ -94,6 +94,7 @@
         self.arena_size = arena_size
         self.page_size = page_size
         self.small_request_threshold = small_request_threshold
+        self.arenas_count = 0
         #
         # 'pageaddr_for_size': for each size N between WORD and
         # small_request_threshold (included), contains either NULL or
@@ -311,6 +312,7 @@
         arena.freepages = firstpage
         self.num_uninitialized_pages = npages
         self.current_arena = arena
+        self.arenas_count += 1
         #
     allocate_new_arena._dont_inline_ = True
 
@@ -398,6 +400,7 @@
                     llarena.arena_reset(arena.base, self.arena_size, 4)
                     llarena.arena_free(arena.base)
                     lltype.free(arena, flavor='raw', track_allocation=False)
+                    self.arenas_count -= 1
                     #
                 else:
                     # Insert 'arena' in the correct arenas_lists[n]


More information about the pypy-commit mailing list