Thanks Jeff, This is the recommendation I was expecting to get. I will run a high concurrency test on a single engine and single compiled code, with new scopes for each request and see where it takes me. Do I need any locks on the engine itself when Getting the scope (which could be called from many threads at the same time)?
I have another question related to performance. Right now I have a number of parameters that I need to pass to the CompiledCode and I use Microsoft.Scripting.ScopeStorage.SetValue and then create the scope using this. Is there a more efficient way to pass parameters to the CompiledCode? Like creating an single "parameter" object which is well known by both the IronPython code and my C# code? Thanks Christos -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Jeff Hardy Sent: Monday, June 07, 2010 6:09 PM To: Discussion of IronPython Subject: Re: [IronPython] Multi threaded engine On Mon, Jun 7, 2010 at 7:14 AM, Christos Pavlides <[email protected]> wrote: > I am thinking that it could be better if the ScriptEngine and CompiledCode > are thread safe, and if I create one static engine an one static > CompliledCode then this will minimize the compile time since the rules will > have to be compiled one time and then reused for all threads. My understanding is that this is the case - for NWSGI I use a single engine (per AppDomain, but that's not important) and each script is compiled once into a CompiledCode object. On each request it gets a new scope from the engine, finds the CompiledCode for the requested script, and executes it in that scope. IIS can have a lot of worker threads handling requests at any time, so it's basically the same scenario you have. As long as you don't reuse scopes (and they're very cheap to create) you should be just fine. - Jeff _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
