[pypy-svn] r68782 - in pypy/branch/gc-dump-heap/pypy/rpython/memory: gc test

fijal at codespeak.net fijal at codespeak.net
Tue Oct 27 11:59:53 CET 2009


Author: fijal
Date: Tue Oct 27 11:59:51 2009
New Revision: 68782

Modified:
   pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/semispace.py
   pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_transformed_gc.py
Log:
Compute total amount of objects, because (of course) varsized structs can
have different sizes. Should fix the apparent difference between number
of observed objects and memory consumed


Modified: pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/semispace.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/semispace.py	(original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/memory/gc/semispace.py	Tue Oct 27 11:59:51 2009
@@ -651,7 +651,8 @@
         self._tracked_dict.add(adr)
         idx = llop.get_member_index(lltype.Signed, self.get_type_id(adr))
         self._ll_typeid_map[idx].count += 1
-        self._ll_typeid_map[idx].size = self.get_size(adr)
+        totsize = self.get_size(adr) + self.size_gc_header()
+        self._ll_typeid_map[idx].size += llmemory.raw_malloc_usage(totsize)
         self.trace(adr, self.track_heap_parent, adr)
 
     def _track_heap_root(self, root):

Modified: pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_transformed_gc.py
==============================================================================
--- pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_transformed_gc.py	(original)
+++ pypy/branch/gc-dump-heap/pypy/rpython/memory/test/test_transformed_gc.py	Tue Oct 27 11:59:51 2009
@@ -4,7 +4,7 @@
 from pypy.translator.c import gc
 from pypy.annotation import model as annmodel
 from pypy.annotation import policy as annpolicy
-from pypy.rpython.lltypesystem import lltype, llmemory, llarena
+from pypy.rpython.lltypesystem import lltype, llmemory, llarena, rffi
 from pypy.rpython.memory.gctransform import framework
 from pypy.rpython.lltypesystem.lloperation import llop, void
 from pypy.rpython.memory.gc.marksweep import X_CLONE, X_POOL, X_POOL_PTR
@@ -809,8 +809,9 @@
                 s = lltype.malloc(S)
                 l1.append(s)
                 l2.append(s)
-                l3.append(s)
-                l4.append(s)
+                if i < 3:
+                    l3.append(s)
+                    l4.append(s)
             # We cheat here and only read the table which we later on
             # process ourselves, otherwise this test takes ages
             llop.gc__collect(lltype.Void)
@@ -820,6 +821,7 @@
             b = 0
             c = 0
             d = 0
+            e = 0
             for i in range(len(tb)):
                 if tb[i].count == 10:
                     a += 1
@@ -830,13 +832,19 @@
                 if tb[i].count == 4:
                     b += 1
                     c += tb[i].links[nr]
+                    e += tb[i].size
             return d * 1000 + c * 100 + b * 10 + a
         return f
 
     def test_gc_dump_heap(self):
         run = self.runner("gc_dump_heap")
         res = run([])
-        assert res == 4011
+        assert res % 10000 == 2611
+        totsize = (res / 10000)
+        size_of_int = rffi.sizeof(lltype.Signed)
+        assert (totsize - 26 * size_of_int) % 4 == 0
+        # ^^^ a crude assumption that totsize - varsize would be dividable by 4
+        #     (and give fixedsize)
         
 # ________________________________________________________________
 



More information about the Pypy-commit mailing list