Author: Armin Rigo <[email protected]>
Branch: stm-thread-2
Changeset: r58981:5a97f72b3931
Date: 2012-11-18 10:57 +0100
http://bitbucket.org/pypy/pypy/changeset/5a97f72b3931/
Log: "extra threshold" support in stmgc.
diff --git a/pypy/rpython/memory/gc/stmgc.py b/pypy/rpython/memory/gc/stmgc.py
--- a/pypy/rpython/memory/gc/stmgc.py
+++ b/pypy/rpython/memory/gc/stmgc.py
@@ -171,6 +171,7 @@
from pypy.rpython.memory.gc import stmshared
self.stm_operations = stm_operations
self.nursery_size = nursery_size
+ self.maximum_extra_threshold = 0
self.sharedarea = stmshared.StmGCSharedArea(self)
#
def _stm_duplicate(obj): # indirection to hide 'self'
@@ -335,6 +336,15 @@
return localobj
# ----------
+ # set_extra_threshold support
+
+ def set_extra_threshold(self, reserved_size):
+ if reserved_size > self.maximum_extra_threshold:
+ self.maximum_extra_threshold = reserved_size
+ stmtls = self.get_tls()
+ stmtls.set_extra_threshold(reserved_size)
+
+ # ----------
# id() and identityhash() support
def id(self, gcobj):
diff --git a/pypy/rpython/memory/gc/stmtls.py b/pypy/rpython/memory/gc/stmtls.py
--- a/pypy/rpython/memory/gc/stmtls.py
+++ b/pypy/rpython/memory/gc/stmtls.py
@@ -45,6 +45,8 @@
# never changes.
self.nursery_size = self.gc.nursery_size
self.nursery_start = self._alloc_nursery(self.nursery_size)
+ self.extra_threshold = 0
+ self.set_extra_threshold(self.gc.maximum_extra_threshold)
#
# --- a thread-local allocator for the shared area
from pypy.rpython.memory.gc.stmshared import StmGCThreadLocalAllocator
@@ -107,6 +109,19 @@
self.nursery_free = NULL
self.nursery_top = NULL
+ # ----------
+ # set_extra_threshold support
+
+ def set_extra_threshold(self, reserved_size):
+ ll_assert(self.nursery_free != NULL,
+ "set_extra_threshold: not in a transaction")
+ diff = reserved_size - self.extra_threshold
+ if diff > 0 and self.nursery_free + diff > self.nursery_top:
+ self.local_collection()
+ self.nursery_size -= diff
+ self.nursery_top -= diff
+ self.extra_threshold += diff
+
# ------------------------------------------------------------
def start_transaction(self):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit