[pypy-svn] r68301 - in pypy/trunk/pypy/rpython: lltypesystem memory/gc

arigo at codespeak.net arigo at codespeak.net
Sat Oct 10 16:11:11 CEST 2009


Author: arigo
Date: Sat Oct 10 16:11:10 2009
New Revision: 68301

Modified:
   pypy/trunk/pypy/rpython/lltypesystem/llarena.py
   pypy/trunk/pypy/rpython/memory/gc/generation.py
Log:
Don't use /dev/zero just to clear the nursery.
That's a bit nonsense and going into system calls
actually takes more time.


Modified: pypy/trunk/pypy/rpython/lltypesystem/llarena.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/llarena.py	(original)
+++ pypy/trunk/pypy/rpython/lltypesystem/llarena.py	Sat Oct 10 16:11:10 2009
@@ -282,8 +282,12 @@
 
 def arena_reset(arena_addr, size, zero):
     """Free all objects in the arena, which can then be reused.
-    The arena is filled with zeroes if 'zero' is True.  This can also
-    be used on a subrange of the arena."""
+    This can also be used on a subrange of the arena.
+    The value of 'zero' is:
+      * 0: don't fill the area with zeroes
+      * 1: clear, optimized for a very large area of memory
+      * 2: clear, optimized for a small or medium area of memory
+    """
     arena_addr = _getfakearenaaddress(arena_addr)
     arena_addr.arena.reset(zero, arena_addr.offset, size)
 
@@ -385,8 +389,11 @@
 
 def llimpl_arena_reset(arena_addr, size, zero):
     if zero:
-        clear_large_memory_chunk(arena_addr, size)
-register_external(arena_reset, [llmemory.Address, int, bool], None,
+        if zero == 1:
+            clear_large_memory_chunk(arena_addr, size)
+        else:
+            llmemory.raw_memclear(arena_addr, size)
+register_external(arena_reset, [llmemory.Address, int, int], None,
                   'll_arena.arena_reset',
                   llimpl=llimpl_arena_reset,
                   llfakeimpl=arena_reset,

Modified: pypy/trunk/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/trunk/pypy/rpython/memory/gc/generation.py	(original)
+++ pypy/trunk/pypy/rpython/memory/gc/generation.py	Sat Oct 10 16:11:10 2009
@@ -332,7 +332,7 @@
             if self.young_objects_with_id.length() > 0:
                 self.update_young_objects_with_id()
             # mark the nursery as free and fill it with zeroes again
-            llarena.arena_reset(self.nursery, self.nursery_size, True)
+            llarena.arena_reset(self.nursery, self.nursery_size, 2)
             if self.config.gcconfig.debugprint:
                 llop.debug_print(lltype.Void,
                                  "survived (fraction of the size):",



More information about the Pypy-commit mailing list