[IronPython] IPyb5 performance
Dino Viehland
dinov at microsoft.com
Mon Sep 29 01:55:30 CEST 2008
Also not passing a scope is probably bound to help - especially if the perf critical code is in this file and accesses lots of globals. Do .Compile, get the DefaultScope, update that w/ the vars you want set, and then just do .Execute().
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jimmy Schementi
Sent: Sunday, September 28, 2008 1:32 PM
To: Discussion of IronPython
Subject: Re: [IronPython] IPyb5 performance
Make that last line call compile and see if it helps. When the Silverlight integration was written that gave a 4x speedup when using top-level functions/variables:
source.Compile().Execute(mainScope);
Not sure if that's the case anymore, but it's worth a try.
~js
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ronnie Maor
Sent: Saturday, September 27, 2008 11:22 PM
To: Discussion of IronPython
Subject: [IronPython] IPyb5 performance
Hi all,
I've finally managed to get my code running correctly under IPy2b5 - thanks everyone who helped!
I'm now left with a performance problem. My code seems to run roughly 2 times slower:
* infra tests regressed from 19 seconds in IPy 1.1.1 to 33 seconds in IPy2b5
* application level tests regressed from 375 seconds in 1.1.1 to 705 seconds in IPy2b5
(these are single measurements, but variance is not too big - about 5%)
startup time is also much longer, but I can live with that.
before trying to pinpoint the bottlenecks, I wanted to check I'm not missing something stupid, like turning on optimizations in the DLR...
below is the hosting code I'm using to run the tests. I tried with and without "Debug" flag, and it doesn't seem to change anything (except debug allows me to understand the stack traces). I can also run the infra tests with ipy directly, which showed that -O and -OO don't help either.
Is there something else I should be doing? any tips?
thanks!
// set up runtime and engine
Dictionary<string, object> runtimeOptions = new Dictionary<string, object>();
runtimeOptions["Debug"] = true;
ScriptRuntime runtime = IronPython.Hosting.Python.CreateRuntime(runtimeOptions);
runtime.LoadAssembly(typeof(String).Assembly); // Add reference to System
runtime.LoadAssembly(typeof(Uri).Assembly); // Add reference to mscorlib
engine = runtime.GetEngine("Python");
....
// run file as __main__
engine.SetSearchPaths(new string[] {".", progdir, backend_dir, stdlib_dir});
List argv = new List();
argv.append(filename);
for (int i = 2; i < args.Length; ++i)
argv.append(args[i]);
engine.GetSysModule().SetVariable("argv", argv);
mainScope = engine.CreateScope();
mainScope.SetVariable("__name__", "__main__");
var main_module = Microsoft.Scripting.Hosting.Providers.HostingHelpers.GetScope(mainScope);
runtime.Globals.SetVariable("__main__", main_module);
mainScope.SetVariable("__file__",filename);
ScriptSource source = engine.CreateScriptSourceFromFile(filename, Encoding.Default, SourceCodeKind.Statements);
source.Execute(mainScope);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080928/33ed549d/attachment.html>
More information about the Ironpython-users
mailing list