<html><body><div><br><br>On 28 Jul, 2010,at 12:56 PM, Michael Foord <fuzzyman@voidspace.org.uk> wrote:<br><br></div><div><blockquote type="cite"><div><div class="_stretch">On 28/07/2010 11:50, Nick Coghlan wrote:<br>
> On Tue, Jul 27, 2010 at 12:33 AM, Ronald Oussoren<br>
> <ronaldoussoren@mac.com> wrote:<br>
> <br>
>> In my opinion the GIL is a weak point of CPython and it would be nice if it<br>
>> could be fixed. That is however easier said than done, a number of people<br>
>> have tried in the past and ran into implementation limitations like our<br>
>> refcounting garbage collector that make hard to remove the GIL without<br>
>> either rewriting lots of code, or running into a brick wall<br>
>> performance-wise.<br>
>><br>
>> The HotPy presentation at EuroPython shows that it is possible to remove the<br>
>> GIL, although at the cost of replacing the garbage collector and most likely<br>
>> breaking existing C extensions (although the HotPy author seemed to have a<br>
>> possible workaround for that).<br>
>> <br>
> This is the kind of approach that seems to hold the most promise of<br>
> removing the GIL without incurring the single-threaded performance hit<br>
> that has been the achilles heel of previous attempts at creating a<br>
> free-threaded CPython implementation. With first IronClad and now PyPy<br>
> blazing the trail in interfacing a garbage collected Python<br>
> implementation with deterministic refcounting for C extension modules,<br>
> it seems plausible that this kind of approach may eventually prove<br>
> acceptable.<br>
><br>
> Furthermore, the with statement now provides a superior alternative to<br>
> application level tricks that previously relied on deterministic<br>
> refcounting.<br>
><br>
> While multi-threading does break down beyond a certain number of<br>
> cores, it *is* possible to do safely (particularly using queues to<br>
> pass references around) and can avoid plenty of serialisation overhead<br>
> when dealing with sizable data structures<br>
> <br>
<br>
Breaking binary compatibility with C extensions would be "difficult" <br>
once PEP 384 (stable binary ABI) has gone into effect. As you intimate, <br>
Ironclad demonstrates that C extensions *can* be interfaced with a <br>
different garbage collection system whilst maintaining binary <br>
compatibility. It does impose constraints however (which is why the PyPy <br>
c-ext implementors chose source compatibility rather than binary <br>
compatibility).</div></div></blockquote><span> </span></div><div>The HotPy author mentioned that he has a scheme where refcounts could be used by C extensions while the system natively uses a copying collector, but I got the impression that this was not fully fleshed out yet.</div><div><br></div><div>Apple's Objective-C garbage collector has a simular feature: you can use CFRetain/CFRelease to manage refcounts and the GC will only collect objects where the CF reference count is 0. This is a non-copying collector in a C environment though, which makes this scheme easier to implement than with a full generational copying collector.</div><div><br></div><div>It should therefore be possible to have an interpreter where the VM uses a real GC and while extensions using the stable ABI could work as is, but that probably requires that Py_INCREF and Py_DECREF expand into function calls in the stable ABI.</div><div><br></div><div>Implementing this would still be a significant amount of work.</div><div><br></div><div>Ronald</div><div><br></div><div><blockquote type="cite"><div><div class="_stretch"><br>
<br>
Michael<br>
<br>
<br>
<br>
> Cheers,<br>
> Nick.<br>
><br>
> <br>
<br>
<br>
-- <br>
<a href="http://www.ironpythoninaction.com/" _mce_href="http://www.ironpythoninaction.com/">http://www.ironpythoninaction.com/</a><br>
<a href="http://www.voidspace.org.uk/blog" _mce_href="http://www.voidspace.org.uk/blog">http://www.voidspace.org.uk/blog</a><br>
<br>
READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.<br>
<br>
<br>
</div></div></blockquote></div></body></html>