The default scope is the default for that particular piece of code. What we do is generate a .NET type which has a bunch of static fields in it - 1 for each global that is accessed. The compiled code then can access these directly and we wrap this all up in a Python dictionary object for late bound access. When you run against a non-default scope we have to run against a piece of code which is compiled to lookup all the globals from a real dictionary.
It'll be interesting to hear what you find out what you can narrow it down to. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ronnie Maor Sent: Monday, September 29, 2008 12:16 AM To: Discussion of IronPython Subject: Re: [IronPython] IPyb5 performance thanks for the help. I tried both suggestions, but unfortunately it didn't change anything. I now use a benchmark that builds a typical setup and then checks performance of calculations in steady state: Ipy 1.1.1: total time: 80 sec. single "compute actions": 0.23 sec Ipy 2.0b5: total time: 200 sec. single "compute actions": 1.2 sec I believe the changes didn't help because most of the code is python, so the main is just the "tip of the iceberg". The main file is 64 lines and the code it launches is about 15K lines. IIUC what Dino said, the changes you proposed only affect how the 64 lines are run. The rest are compiled when they are imported (directly or indirectly by the main module) and run in their own scopes. the good and bad news is that for steady state the degradation is 600%. The good part is that maybe it's this bad because I'm using one or two flows which have a very specific and silly problem (like the **kw which you fixed already). I will try to focus the problem better once I've gotten over Rosh Hashana dinner :-) btw, the only way I found to get the default scope was through CompiledCode.DefaultScope. Expected it to be accessible directly from the engine. Is there are reason it's not? (or have I just missed it) thanks Ronnie On Mon, Sep 29, 2008 at 2:55 AM, Dino Viehland <[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>> wrote: 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: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> [mailto:[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>] 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: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]> [mailto:[EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>] 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); _______________________________________________ Users mailing list Users@lists.ironpython.com<mailto:Users@lists.ironpython.com> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com