[pypy-commit] extradoc extradoc: Cannot compress the whole chain! Discovered this by "targetjit1" in
arigo
noreply at buildbot.pypy.org
Thu Sep 13 07:33:41 CEST 2012
Author: Armin Rigo <arigo at tunes.org>
Branch: extradoc
Changeset: r4803:6a8e4f80ba44
Date: 2012-09-12 23:41 +0200
http://bitbucket.org/pypy/extradoc/changeset/6a8e4f80ba44/
Log: Cannot compress the whole chain! Discovered this by "targetjit1" in
pypy.
diff --git a/talk/stm2012/stmimpl.rst b/talk/stm2012/stmimpl.rst
--- a/talk/stm2012/stmimpl.rst
+++ b/talk/stm2012/stmimpl.rst
@@ -409,11 +409,8 @@
def PossiblyUpdateChain(G, R, R_Container, FieldName):
if R != G and Rarely():
- # compress the chain
- while G->h_revision != R:
- G_next = G->h_revision
- G->h_revision = R
- G = G_next
+ # compress the chain one step (cannot compress the whole chain!)
+ G->h_revision = R
# update the original field
R_Container->FieldName = R
@@ -425,6 +422,12 @@
the modified values. It works because the original and each modified
value are all interchangeable as far as correctness goes.
+However, note that if the chain is longer than one item, we cannot fix
+the whole chain -- we can only fix the first item. The issue is that we
+cannot at this point reliably walk the chain again until we reach ``R``,
+precisely because *another* thread might be fixing the *same* chain in
+such a way that ``R`` is then skipped.
+
``Rarely`` uses a thread-local counter to return True only rarely. We
do the above update only rarely, rather than always, although it would
naively seem that doing the update always is a good idea. The problem
More information about the pypy-commit
mailing list