[IronPython] Performance of IronPython 2 Beta 4 and IronPython 1
dinov at exchange.microsoft.com
Thu Aug 14 09:43:10 PDT 2008
Awesome information! I'll start taking a look through all of this and let you know what I can improve.
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Thursday, August 14, 2008 6:15 AM
To: Discussion of IronPython
Subject: [IronPython] Performance of IronPython 2 Beta 4 and IronPython 1
I've ported Resolver One to run on IronPython 2 Beta 4 to check for any potential problems (we will only do a *proper* port once IP 2 is out of beta).
The basic porting was straightforward and several bugs have been fixed since IP 2 B3 - many thanks to the IronPython team.
The good news is that Resolver One is only 30-50% slower than Resolver One on IronPython 1! (It was 300 - 400% slower on top of IP 2 B3.) Resolver One is fairly heavily optimised around the performance hotspots of IronPython 1, so we expect to have to do a fair bit of profiling and refactoring to readjust to the performance profile of IP 2.
Having said that, there are a few oddities (and the areas that slow down vary tremendously depending on which spreadsheet we use to benchmark it
- making it fairly difficult to track down the hotspots).
We have one particular phase of spreadsheet calculation that takes 0.4seconds on IP1 and around 6 seconds on IP2, so I have been doing some micro-benchmarking to try and identify the hotspot. I've certainly found part of the problem.
For those that are interested I've attached the very basic microbenchmarks I've been using. The nice thing is that in *general* IP2 does outperform IP1.
The results that stand out in the other direction are:
Using sets with custom classes (that define '__eq__', '__ne__' and
'__hash__') seems to be 6 times slower in IronPython 2.
Adding lists together is about 50% slower.
Defining functions seems to be 25% slower and defining old style classes about 33% slower. (Creating instances of new style classes is massively faster though - thanks!)
The code I used to test sets (sets2.py) is as follows:
from System import DateTime
def __init__(self, val):
self.val = val
def __eq__(self, other):
return self.val == other.val
return not self.__eq__(other)
a = set()
for i in xrange(100000):
Thing(i) in a
Thing(i+2) in a
return (DateTime.Now -s).TotalMilliseconds
s = DateTime.Now
Interestingly the time taken is exactly the same if I remove the definition of '__hash__'.
The full set of results below:
Results in milliseconds with a granularity of about 15ms and so an accuracy of +/- ~60ms.
All testing with 10 000 000 operations unless otherwise stated.
Empty loop (overhead):
Create instance newstyle:
Create instance oldstyle:
Create function: 25% slower
Define newstyle (1 000 000):
Define oldstyle (1 000 000): 33% slower
Comparing (== and !=):
Sets (with numbers):
Lists (10 000): 50% slower
Recursion (10 000):
Sets2 (100 000): 600% slower
I'll be doing more as the 600% slow down for sets and the 50% slow down for lists accounts for some of the dependency analysis problem but not all of it.
Sample disclaimer text
More information about the Users