[IronPython] Bad performance calling .NET method
laurionb at microsoft.com
Tue Apr 20 11:10:34 CEST 2010
I am getting terrible performance invoking a C# method from IP. I have a static class called Api with this method:
public static void MakeKey(JET_SESID sesid, JET_TABLEID tableid, string data, Encoding encoding, MakeKeyGrbit grbit)
When I call it directly from C# I get about 3M calls/second. In IronPython I get only 50,000 calls/second -- a 60X slowdown!
The method is overloaded. When I call these overloads I get good performance (~ 1M calls/second):
public static void MakeKey(JET_SESID sesid, JET_TABLEID tableid, int data, MakeKeyGrbit grbit)
public static void MakeKey(JET_SESID sesid, JET_TABLEID tableid, float data, MakeKeyGrbit grbit)
public static void MakeKey(JET_SESID sesid, JET_TABLEID tableid, byte data, MakeKeyGrbit grbit)
(for the last overload I passed in the string turned into a byte array with Encoding.GetBytes())
Things I have tried that didn't help:
- Changing the name of the method so it was unique.
- Calling the method using Api.MakeKey.Overloads[...]
- Calling other methods I have that take string arguments. They were fast.
When I profile the code the time shows up in mscorwks.dll (56%) and mscorlib.ni.dll (17%). IronPython is only 8% and my code is 6%.
Can anyone help me work out what is going wrong? I have a short, turn-key repro of this. MakeKey is a very commonly used method so having it be so slow is crippling.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users