1. Pypy
  2. Untitled project
  3. extradoc

Commits

Armin Rigo  committed 6a8e4f8

Cannot compress the whole chain! Discovered this by "targetjit1" in
pypy.

  • Participants
  • Parent commits f0b7758
  • Branches extradoc

Comments (0)

Files changed (1)

File talk/stm2012/stmimpl.rst

View file
  • Ignore whitespace
 
     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
 
 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