[IronPython] Jit leak in defaultdict for Ipy 2.6.2
dinov at microsoft.com
Mon Nov 29 18:40:54 CET 2010
Defaultdict is creating a new invoke binder - it should be getting the binder from PythonContext using the Invoke(CallSignature) method. Because it creates a new binder each time we are getting no caching of the rules across defaultdict instances and it'll end up generating a new method to handle the missing call. It is collectible (so not really a leak) but it is really bad from a performance perspective.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Idan Zaltzberg
Sent: Monday, November 29, 2010 4:10 AM
To: Discussion of IronPython
Subject: [IronPython] Jit leak in defaultdict for Ipy 2.6.2
I have noticed the following method always adds a jitted method (looking at the ".NET CLR Jit" performance counter) when it is run:
d = defaultdict(int)
I created my own implementation of defaultdict (in ipy):
def __init__(self, cls):
self.cls = cls
def __getitem__(self, key):
if key not in self:
self[key] = self.cls()
return super(defaultdict, self).__getitem__(key)
And I noticed that it does not leak JIT and it works 200 times faster when running the method f().
Can you please look why this happens in the current implementation?
Also I was wondering if there are any other utility methods that use similar code and probably will have the same problem.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users