Unfortunately, no scripting language we have encountered
has ever done proper threading to the point that you could even begin to do that.

Lua is one of the better ones in a threaded env only because they solved the problem by making a tiny VM that
can be easily reproduced thousands of times.  You still can't share a lua vm across threads or it will crash because they
use lots of setjmp longjmp calls to travel between their virtual stack and the real one.

As a matter of fact, spidermonkey has code that tries to be threadsafe (but you have to enable it, --with-threadsafe makes me nervous =]) and it shares as much as it can already and we have debated changing it so it creates a whole
JS instance per call just because of all the garbage collection and thread safety issues we have encountered.
you have to call a whole bunch of hidden mutexes marked suspend and resume etc everywhere in the code where you
transition from executing script side code to a blocking FreeSWITCH function.


Really, the only point in my original comment was that if you want to scale up something that uses scripting the first way to save
resources is to not leave the script open while you do something you know will take a long time "playing a 2 hour file, bridging a call, joining a conference" because the script resources are allocated and doing nothing this whole time and they all share a global garbage collector.  if you don't need to remain in the script just transfer the call to a static extension and close it.  It's just a suggestion really.



On Thu, May 14, 2009 at 4:56 PM, David Knell <dave@3c.co.uk> wrote:
On Thu, 2009-05-14 at 12:31 -0500, Brian West wrote:
> Its obvious if you look at the size of the JS VM vs the lua VM.. it
> would clearly scale better not needing megs and megs of ram per call
> vs about 160kb for lua.

Isn't this a bit of a non sequitur, given that there ought to be just
one copy of the JS interpreter in RAM which is shared across all of the
calls/threads which need to use it?

--Dave



--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale@hotmail.com
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org
pstn:213-799-1400