I have a very strange problem, I have a c# application (quite complex) that among other things calls an Ironpython script that exchanges some data with the C# code. The IronPython script do a set of calculations and mainly it passes from around 30 rules checking the input data and collects the results of each, which returns as the results set. This script is called repeatedly every 20 sec for about 60 times before the whole process ends. The result is that the CPU load increases continuously up to 100% and stays there until the end of the process.
Now, when the script is called either from visual studio as an IronPython project or run as a python script from command prompt (ipy), even as a python script (not IronPython) using Anaconda and cPython and for all of the above with a call repetition like the process, it runs normally without any problem no CPU load more that some spikes that do not go higher than 50% .
When I try to analyze the whole application with visual studio I get something like this IronPython.Runtime.FunctionCode+<>c__DisplayClass19_0.b__0 which appears to have like 500K samples(inclusive, exclusive) and consumes something like the 90% of the CPU load.
I understand that my problem is a bit specific and my question a bit generic but is too complicated to share something more. So, apologies if somebody feels that the picture is not complete ... I accept it, it is not!
What I would like to ask the community is if somebody else has phased a similar problem (similar pattern) and managed to check a few things and maybe resolve the problem or even workaround it.
For those who may wonder, we have already restructured and checked the IronPython code to avoid unnecessary calls or repetitive (endless) loops, etc. Also, even when the CPU is loaded to 100% the script returns the correct results and does not show any issues in operation.
Finally we have tested all know and documented ways to call the IronPython script from within c# (dynamic object, compiled, plain py script and assembly dll), all of them had the same (more or less) CPU performance issue.
My feeling is that it is an issue with how .Net calls IronPython scripts from within C# .
Many thanks in advance for reading my question and even more for your answers.
Regards, IK