[Mono-devel-list] Embedding Mono in Second Life

Jim Purbrick jimpurbrick at yahoo.co.uk
Tue Apr 26 09:37:59 EDT 2005

I'm currently looking at embedding Mono in Second Life
(www.secondlife.com) to allow user scripting.

The hope is that Mono's JIT compilation will provide a
large performance boost over the current script
interpreter and that, ultimately, we'll be able to use
multiple programming languages to script the world.

I've now completed the compiler for the Linden
Scripting Language
(http://www.sluniverse.com/lsl.html) which is used to
script Second Life. The new LSL compiler produces
bytecode which Mono executes between 300 and 500 times
faster than the current LSL interpreter. 

I'm now looking at embedding the Mono runtime within
Second Life and still have a few questions, which i've
mentioned before. 

The biggest issue is that I need to be able to migrate
running scripts to new servers within the Second Life
grid. I can see 3 possible ways to do this:

1) Migrate entire processes between servers using
something like Mosix or Xen. I'm not sure if this
would be possible with Mono processes or whether
migrating processes would be too heavyweight.

2) Have the managed code call in to unmanaged code
which extracts the logical stack from the native
stack.   This approach has been used to serialize Java
threads, but relied on the JVM deoptimising JIT
compiled code back in to bytecode, a feature which was
implemented to make debugging easier.

3) Inject bytecode to implement user level threading
in a similar way that yield is implemented in C#. This
starts looking a lot like stackless python or
picothreads in Java. Code is added to allow methods to
save their arguments, local variables and current
position in to an object on the heap which can be
serialized over to the new server.

I'm currently looking to implement the 3rd option
which adds 5% to the runtime of the logic benchmark
and 300% to the execution time of the fibonaci

I'd like to implement this as a bytecode translator so
that it could add bytecode threading to CIL code
produced by any compiler. Are there any CIL parsing or
generation libraries I can use for this?

I also need to limit memory allocated by each script
object, which I plan to do by using the profiler API
to intercept memory allocations.

Does all this sound reasonable? Are there any other
things I need to consider? I'd really like to know
everyone's opinions before I start the integration
work in anger.

Thanks for all your help so far,



Send instant messages to your online friends http://uk.messenger.yahoo.com 

More information about the Mono-devel-list mailing list