<div dir="ltr">Hi Steve<div><br></div><div>Thank you for your message. I think my response below allows us to go move forward.</div><div><br></div><div>WHAT'S THE PROBLEM<br>You asked:<br>> What problem are you trying to solve?<br>> Its okay if there is no immediate problem, that you're just exploring<br>> alternative garbage collection strategies. Or if you're trying to remove<br>> the GIL.<br><br>I'm exploring. I hope we'll find something that helps CPython run faster on multi-core machines, at least for some users. I hope this helps you understand where I'm coming from.</div><div><br></div><div>Please, in this thread, can we confine ourselves to getting a better understanding of multi-core reference count garbage collection. That is for me already hard enough, in isolation, without mixing in other issues.</div><div><br>RACE CONDITION<br>You wrote<br>> multithreaded reference counting can suffer from race conditions<br>> when incrementing or decrementing<br>In support you referenced (the very useful)<br>> <a href="http://flyingfrogblog.blogspot.com/2013/09/how-do-reference-counting-and-tracing.html">http://flyingfrogblog.blogspot.com/2013/09/how-do-reference-counting-and-tracing.html</a><br>The relevant statement on that page is<br>> multithreaded reference counting is non-deterministic because increments and decrements race. <br><br></div><div><div>According to <a href="https://en.wikipedia.org/wiki/Race_condition">https://en.wikipedia.org/wiki/Race_condition</a><br></div><div>---</div><div>A race condition or race hazard is the behavior of an electronics, software, or other system where the output is dependent on the sequence or timing of other uncontrollable events. It becomes a bug when events do not happen in the order the programmer intended.</div><div>---</div><div><br></div><div>I like this, but I would change the last sentence to read</div><div>> It becomes a bug when the outputs are incorrect, for example are in a wrong order.</div><div>Sometimes, eg iterating over a set, there is no intended order.</div><div><br></div><div>DEALING WITH THE RACE CONDITION</div><div>There is a race condition (or hazard) in buffered reference counting garbage collection. You wrote that this "would be a bad thing". I hope that, at the expense of some complexity in the code, the potential for a bug arising from race hazard can be avoided. Certainly, a bug in garbage collection is a bad thing.</div><div><br></div><div>I was aware of this race hazard when I started this discussion thread. In my first post of yesterday I made "a start on the hard part" of "doing the right thing". I also then said</div><div><div>> The remainder of the hard part is to get hold of adjusted reference</div><div>> counts, without having to lock the worker threads.</div></div><div><br></div><div>GOING FORWARD</div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">I hope in the next day or two to make a start on the remainder of the hard part. Your link to flyingfrog is valuable. I hope you'll contribute again.</span><br></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Finally, you might help you to know that I'm trying in my exploration to use top-down or stepwise design.</span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">-- </span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Jonathan</span></div><div><div><br></div><div><br></div></div></div></div>