[IronPython] IronPython 2.0A2 performance problems

Dino Viehland dinov at exchange.microsoft.com
Tue Jul 17 18:40:05 CEST 2007

Performance is a rather interesting area in IronPython currently.  We are effectively changing the way we dispatch to methods internally from the old method (which was largely based around using interfaces for calling methods.  Our built-in functions would be 1st class objects which were ICallable* and they would hold onto a cached generated delegate which would do fast dispatch to the .NET method).  The brave new world is all based around DynamicSite's which are caching this information at the call site and doing fast(er) dispatch from the call site.

In between alpha 1 and alpha 2 we completely ripped out the cached site inside of the callable objects for built-in functions and we were able to get most of the calls going through the DynamicSite mechanism instead.  Unfortunately there are still some cases where we don't go through that code path and when that happens performance degrades very significantly.

The problem here is w/ the indexer is not being optimized.  To put this into concrete terms we have "Action"s (name will probably change) one of which is the DoOperationAction.  DoOperationAction has various operation types which include GetItem/SetItem.  In Alpha 2 we have no optimized code paths for GetItem/SetItem and so this goes really, really slow.

If you run (on a debug build) w/ -X:TrackPerformance option you'll see a summary of results such as:

---- Performance Summary ----

Total DictInvoke = 101086
Total ReflectedTypes = 63
Total OverAllocate = 4
Total Compiler = 25
Total field = 199 (time = ~0.0003597938507 secs)
Total calls = 100014 (calltime = ~0.514495569297 secs)
Total Properties = 2

Total Known Times: 0.5148553631477

The costly part here is the calls - DictInvoke also has some costs but nothing compared to the calls.

The good news is I've been working on improving our indexing time so on the next release this will be fixed.  On my machine these numbers look like:

---- Performance Summary ----

Total DictInvoke = 1070
Total ReflectedTypes = 63
Total OverAllocate = 4
Total Compiler = 26
Total field = 195 (time = ~0.0003525618135 secs)
Total calls = 12 (calltime = ~6.1730826E-05 secs)
Total Properties = 2

And the execution time is 1/10th of what it is in Alpha 2.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Arman Bostani
Sent: Monday, July 16, 2007 3:03 PM
To: users at lists.ironpython.com
Subject: [IronPython] IronPython 2.0A2 performance problems

The following code runs about 13 times slower with version 2.0A2 than 1.1!


import System
d = System.Collections.SortedList()
t = System.DateTime.Now
for k in xrange(100000):
     d[k] = k
print 'SortedList time', (System.DateTime.Now - t).Ticks/100000
users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list