[pypy-svn] r49358 - in pypy/dist/pypy/rpython/memory: gc test
arigo at codespeak.net
arigo at codespeak.net
Wed Dec 5 08:01:00 CET 2007
Author: arigo
Date: Wed Dec 5 08:00:58 2007
New Revision: 49358
Modified:
pypy/dist/pypy/rpython/memory/gc/generation.py
pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py
Log:
Ouuuuups! Most var-sized objects were never allocated from the nursery
at all. This is the minimal fix with a test.
Modified: pypy/dist/pypy/rpython/memory/gc/generation.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gc/generation.py (original)
+++ pypy/dist/pypy/rpython/memory/gc/generation.py Wed Dec 5 08:00:58 2007
@@ -125,6 +125,9 @@
itemsize, offset_to_length,
True, False)
+ malloc_fixedsize_clear = malloc_fixedsize
+ malloc_varsize_clear = malloc_varsize
+
# override the init_gc_object methods to change the default value of 'flags',
# used by objects that are directly created outside the nursery by the SemiSpaceGC.
# These objects must have the GCFLAG_NO_YOUNG_PTRS flag set immediately.
Modified: pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py (original)
+++ pypy/dist/pypy/rpython/memory/test/test_transformed_gc.py Wed Dec 5 08:00:58 2007
@@ -9,6 +9,7 @@
from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rpython.memory.gc.marksweep import X_CLONE, X_POOL, X_POOL_PTR
from pypy.rlib.objectmodel import compute_unique_id
+from pypy.rlib.debug import ll_assert
from pypy import conftest
INT_SIZE = struct.calcsize("i") # only for estimates
@@ -861,3 +862,37 @@
run = self.runner(f, nbargs=0)
run([])
+
+class TestGenerationalNoFullCollectGC(GCTest):
+ # test that nursery is doing its job and that no full collection
+ # is needed when most allocated objects die quickly
+
+ gcname = "generation"
+
+ class gcpolicy(gc.FrameworkGcPolicy):
+ class transformerclass(framework.FrameworkGCTransformer):
+ from pypy.rpython.memory.gc.generation import GenerationGC
+ class GCClass(GenerationGC):
+ def semispace_collect(self, size_changing=False):
+ ll_assert(False,
+ "no full collect should occur in this test")
+ GC_PARAMS = {'space_size': 2048,
+ 'nursery_size': 512}
+ root_stack_depth = 200
+
+ def test_working_nursery(self):
+ def f():
+ total = 0
+ i = 0
+ while i < 40:
+ lst = []
+ j = 0
+ while j < 5:
+ lst.append(i*j)
+ j += 1
+ total += len(lst)
+ i += 1
+ return total
+ run = self.runner(f, nbargs=0)
+ res = run([])
+ assert res == 40 * 5
More information about the Pypy-commit
mailing list