<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks for the details on IronPython's implementation B-)<br>
<br>
Hopefully Pypy will eventually get rid of its own Gil, since it doesn't
do refcounting either.<br>
<br>
Regards, <br>
Pascal<br>
<br>
Le 28/05/2011 00:52, Dino Viehland a écrit :
<blockquote
cite="mid:6C7ABA8B4E309440B857D74348836F2E15BFF919@TK5EX14MBXC292.redmond.corp.microsoft.com"
type="cite">
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">In
IronPython we have fine grained locking on our mutable data
structures. In particular we have a custom dictionary type which is
designed to allow lock-free readers on common operations while writers
take a lock. Our list implementation is similar but in some ways
that’s trickier to pull off due to features like slicing so if I recall
correctly we only have lock-free reads when accessing a single
element.
<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">For
.NET data structures they follow the .NET convention which is up to the
data structure. So if you wanted to get every last bit of performance
out of your app you could handle thread safety yourself and switch to
using the .NET dictionary or list types (although they’re a lot less
friendly to Python developers).<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">Because
of these locks on micro-benchmarks that involve simple list/dict
manipulations you do see noticeably worse performance in IronPython vs.
CPython.
<a moz-do-not-send="true"
href="http://ironpython.codeplex.com/wikipage?title=IP27A1VsCPy27Perf&referringTitle=IronPython%20Performance">http://ironpython.codeplex.com/wikipage?title=IP27A1VsCPy27Perf&referringTitle=IronPython%20Performance</a>
- See the SimpleListManipulation and SimpleDictManipulation as the
core examples here. Also CPython’s dictionary is so heavily tuned it’s
hard to beat anyway, but this is a big factor.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);">Finally
one of the big differences with both Jython and IronPython is that we
have good garbage collectors which don’t rely upon reference counting.
So one area where CPython gains from having a GIL is a non-issue for us
as we don’t need to protect ref counts or use interlocked operations
for ref counting.
<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size: 11pt; font-family: "Calibri","sans-serif"; color: rgb(31, 73, 125);"><o:p> </o:p></span></p>
<div
style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue; border-width: medium medium medium 1.5pt; padding: 0in 0in 0in 4pt;">
<div>
<div
style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;">
<p class="MsoNormal"><b><span
style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">From:</span></b><span
style="font-size: 10pt; font-family: "Tahoma","sans-serif"; color: windowtext;">
<a class="moz-txt-link-abbreviated" href="mailto:python-list-bounces+dinov=exchange.microsoft.com@python.org">python-list-bounces+dinov=exchange.microsoft.com@python.org</a>
[<a class="moz-txt-link-freetext" href="mailto:python-list-bounces+dinov=exchange.microsoft.com@python.org">mailto:python-list-bounces+dinov=exchange.microsoft.com@python.org</a>] <b>On
Behalf Of
</b>Pascal Chambon<br>
<b>Sent:</b> Friday, May 27, 2011 2:22 PM<br>
<b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:python-list@python.org">python-list@python.org</a> >> Python List<br>
<b>Subject:</b> GIL in alternative implementations<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";">Hello
everyone,
</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";"> </span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";">I've
already read quite a bit about the reasons for the GIL in CPython, i.e
to summarize, that a more-fine graine locking, allowing real
concurrency in multithreaded applications, would bring too much
overhead for single-threaded python applications.</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";"> </span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";">However,
I've also heard that other python implementations (ironpython,
jython...) have no GIL, and yet nobody blames them for performance
penalties that would be caused by that lack (I especially think about
IronPython, whose performances compare quite well to CPython).</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";"> </span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";">So I'd
like to know: how do these other implementations handle concurrency
matters for their primitive types, and prevent them from getting
corrupted in multithreaded programs (if they do) ? I'm not only
thinking about python types, but also primitive containers and types
used in .Net and Java VMs, which aren't atomic elements either at an
assembly-level point of view.</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";"> </span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";">Do these
VMs have some GIL-like limitations, that aren't spoken about ? Are
there functionings completely different from the CPython VM, so that
the question is not relevant ? Do people consider that they always
concern multithreaded applications, and so accept performance penalties
that they wouldn't allow in their CPython scripts ?</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";"> </span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";">I think
you in advance for your lights on these questions.</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";"> </span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";">Regards,
</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";">Pkl</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";"> </span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";">[[
Important Note: this is a serious question, trolls and emotionally
disturbed persons had better go on their way. ]]</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";"> </span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size: 10pt; font-family: "Arial","sans-serif";"> </span><o:p></o:p></p>
</div>
</div>
</blockquote>
<br>
</body>
</html>