[pypy-svn] r77113 - in pypy/branch/gen2-gc/pypy/rpython/memory/gc: . test
arigo at codespeak.net
arigo at codespeak.net
Thu Sep 16 15:04:45 CEST 2010
Author: arigo
Date: Thu Sep 16 15:04:43 2010
New Revision: 77113
Added:
pypy/branch/gen2-gc/pypy/rpython/memory/gc/test/test_minimark.py (contents, props changed)
Modified:
pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimark.py
Log:
* Tweak the small_request_threshold to ensure that unicode builders
of the default size (100) are also small.
* Write placeholders for all special functions used by gctransform.
Modified: pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimark.py
==============================================================================
--- pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimark.py (original)
+++ pypy/branch/gen2-gc/pypy/rpython/memory/gc/minimark.py Thu Sep 16 15:04:43 2010
@@ -89,8 +89,9 @@
"arena_size": 65536*WORD,
# The maximum size of an object allocated compactly. All objects
- # that are larger are just allocated with raw_malloc().
- "small_request_threshold": 32*WORD,
+ # that are larger are just allocated with raw_malloc(). The value
+ # chosen here is enough for a unicode string of length 100.
+ "small_request_threshold": 52*WORD,
# Full collection threshold: after a major collection, we record
# the total size consumed; and after every minor collection, if the
@@ -355,6 +356,30 @@
# ----------
+ # Other functions in the GC API
+
+ def set_max_heap_size(self, size):
+ XXX
+
+ def can_malloc_nonmovable(self):
+ XXX
+
+ def can_move(self, addr):
+ """Overrides the parent can_move()."""
+ return self.is_in_nursery(addr)
+
+ def shrink_array(self, addr, newsize):
+ XXX
+
+ def malloc_varsize_nonmovable(self, typeid, length):
+ XXX
+
+ def malloc_nonmovable(self, typeid, length, zero):
+ # helper for testing, same as GCBase.malloc
+ XXX
+
+
+ # ----------
# Simple helpers
def get_type_id(self, obj):
@@ -390,10 +415,6 @@
obj = llarena.getfakearenaaddress(obj)
return obj.address[0]
- def can_move(self, addr):
- """Overrides the parent can_move()."""
- return self.is_in_nursery(addr)
-
def get_total_memory_used(self):
"""Return the total memory used, not counting any object in the
nursery: only objects in the ArenaCollection or raw-malloced.
Added: pypy/branch/gen2-gc/pypy/rpython/memory/gc/test/test_minimark.py
==============================================================================
--- (empty file)
+++ pypy/branch/gen2-gc/pypy/rpython/memory/gc/test/test_minimark.py Thu Sep 16 15:04:43 2010
@@ -0,0 +1,20 @@
+from pypy.rpython.lltypesystem import llmemory
+from pypy.rpython.memory.gc.minimark import MiniMarkGC
+
+# Note that most tests are in test_direct.py.
+
+
+def test_stringbuilder_default_initsize_is_small():
+ # Check that pypy.rlib.rstring.INIT_SIZE is short enough to let
+ # the allocated object be considered as a "small" object.
+ # Otherwise it would not be allocated in the nursery at all,
+ # which is kind of bad (and also prevents shrink_array() from
+ # being useful).
+ from pypy.rlib.rstring import INIT_SIZE
+ from pypy.rpython.lltypesystem.rstr import STR, UNICODE
+ #
+ size1 = llmemory.raw_malloc_usage(llmemory.sizeof(STR, INIT_SIZE))
+ assert size1 <= MiniMarkGC.TRANSLATION_PARAMS["small_request_threshold"]
+ #
+ size2 = llmemory.raw_malloc_usage(llmemory.sizeof(UNICODE, INIT_SIZE))
+ assert size2 <= MiniMarkGC.TRANSLATION_PARAMS["small_request_threshold"]
More information about the Pypy-commit
mailing list