Being able to add an independent, event driven program to any object in the world makes scripting in Second Life really intuitive: you add a script and your object becomes an independent agent able to sense its world through event handlers, sit and think and then effect the world through library calls. It's a model that works equally well whether you're coding a fish which swims around looking for food or an information post that just hands out notecards whenever it's poked.
It's an approach that quickly leads to lots of running scripts. Some of the more complex regions constantly run 1000s of scripts. Abbotts Aerodrome runs around 2000 scripts and while most of these are of the give notecard when poked variety they could just as well be calculating PI or running SETI at Home, which means they all need to behave as if they were independent processes running concurrently within the simulator.
Supporting such high levels of concurrency has been one of the major challenges in integrating Mono in to Second Life. Although Mono and the CLI support the concept of independent threads of execution, each Mono thread maps on to an operating system thread which tend to be fairly heavyweight. By default most operating systems reserve megabytes of memory for each thread and don't cope with more than a few dozen running concurrently. Even reducing the allocated stack size to 32K and using the latest thread libraries on Linux doesn't get you much past 1000 running threads before the system starts to wheeze.
The other difficulty with Second Life scripts is that they can migrate between simulators while they are running. You are perfectly entitled to write a script which never stops running and then to tie it to a rocket that you fire in to another region. This is relatively easy to do when all of your script state is in a single 16K block, but much harder when your script has been Just In Time compiled to machine code and its state is scattered throughout memory, registers and an operating system thread.
The solution we implemented for Second Life was to use RAIL on top of .NETs Reflection and Reflection.Emit facilities to inject microthreading in to the script assemblies, an approach used by the JavaGoX and Brakes projects to implement mobile agents in Java. Our microthread injector searches through the script assembly finding points where the script should yield and inducing the types on the stack at those points. It can then inject extra opcodes in to the assembly which copy the stack in to a heap object and cause the script to yield. Whenever a script yields we can restore another script from its previously saved heap object and start it running again, allowing us to schedule many microthreaded scripts on a single operating system thread. By marking the heap objects as serializable we can then just use the standard .NET communication facilities to migrate scripts to remote simulators where they can continue running.
The approach is memory efficient as the memory needed to save the microthread is allocated when it yields, so a large amount of stack space doesn't need to be conservatively reserved up front for the thread. The problems with this approach is that it is expensive in CPU time spent switching microthreads and the space taken up by injected opcodes.
An alternative approach to microthreading Mono has been taken by Tomi Valkeinen who has written some very funky code (inspired by Eve Online's use of Stackless Python) to save and restore the native stack to switch between microthreads. This approach should be a lot faster than opcode injection. We can't currently use Tomi's microthreads for Second Life as the saved stack may contain pointers which can't be transferred to a remote machine, but it may be possible in the future to use Mono's garbage collector to identify the pointers in the native stack and twizzle them in to a form that can be sent to a remote machine.
It would be very cool to build a library which automatically switched between Tomi's microthreading implementation on Mono and Linden Lab microthreading on .NET. People could then build portable microthreaded applications which take advantage of Mono's native microthreading when it's available.
What was the rationale for choosing Mono over Stackless Python?
Will
Posted by: William Wise | June 07, 2006 at 09:11 AM
It's address space, not physical memory, that most operating systems reserve for each thread.
Posted by: anon | June 08, 2006 at 08:11 AM
Because python is slow as shit that's why
Posted by: duh | June 08, 2006 at 11:34 AM
Perhaps, "duh", but your flippant attitude doesn't inspire confidence in your assertion. Stackless Python is used by the folks at Eve who run the largest non-sharded MMORPG and thus has a proven track record so I think it's a reasonable question to ask.
Personally I prefer mono and am glad Linden Labs is putting in the time to add these capabilities to mono. Nevertheless, I'd like to know what advantages mono will have over SP. If there are good reasons I'll personally lobby the Eve devs to consider using mono in the future.
Will
Posted by: William Wise | June 10, 2006 at 05:52 PM
Will, Stackless may well have been a good choice too. The stackless microthreading implementation is certainly mature and proven through its use in Eve. The attraction of Mono is that we want to support the use of mainstream languages to script Second Life alongside maintaining compatability with existing LSL scripts and allowing LSL to be used to develop new scripts in the future. The CLI and Mono are particularly attractive from this perspective. Hilmar Petursson, the CEO of CCP was very interested in the prospect of a microthreaded CLI when I spoke to him about it at the Austin Games Conference last year.
Posted by: Jim Purbrick | June 11, 2006 at 10:34 AM
I believe the decision for using mono is based more on then just threading. It's the JIT that most appeals to LL and garabage collection, as well as the common byte code (CIL) that make up Mono that makes it a win over python. Now if you like Python, you can always use IronPython. :-)
Posted by: Zac Bowling | June 11, 2006 at 06:01 PM
Well, if you can't change the LSL VM cause you don't own it, then yeah, I'd go with SP.
Mono is not what you're looking for..
Posted by: [email protected] | June 19, 2006 at 01:24 AM
I'm delighted you're thinking Mono. I think every day about how wonderful it will be to use it instead of LSL. I'm just not as big a fan of Python as C#. So don't be discouraged by these naysayers!
Posted by: Unoti Quonset | June 21, 2006 at 02:07 PM
Let me reframe the problem.. can you think of an environment similar to SL in which Mono has been a success in?
Posted by: [email protected] | June 22, 2006 at 12:29 AM
I like where this is headed, although I don't understand the comment that "Python is slow." Maybe Stackless Python is slow, but the Eve crew seem to have done fine with it. But IronPython and C# take exactly the same amount of time to chew through my ridiculous recursive Sudoku solver... whatever THAT number's worth...
On the topic of Mono, though, I understand LSL is going to remain the sole scripting language of SL for some time, with no ETA on other langauges being added... BUT I'm optimistic, and hope IPy makes it at least. As it stands, I'm using my own converter ("slython") to generate LSL from Py source because I got sick of having to call a function just to access a list member. =)
Posted by: Jon Molnar | July 11, 2006 at 01:36 AM
"I think every day about how wonderful it will be to use it instead of LSL."
I think it unlikely that you'll be able to use anything other than LSL even after the underlying implementation is using Mono.
What I'd like to know is whether their microthreading scheduler is still going to poll every script every frame for triggering events. And if not, why they don't start out by fixing their current bytecode interpreter?
Posted by: Peter da Silva | July 14, 2006 at 05:05 PM
With a few caveats you can use any language that targets the CLI to script the Mono version of SL now. I've written scripts in C# and CIL assembler already.
The biggest block to using other languages is currently Monos incomplete bytecode verifier, but that is being worked on. If we're going to allow scripts to be compiled using compilers we don't control, we need to be able to verify that the bytecode they produce is safe before we run it.
Posted by: Jim Purbrick | July 25, 2006 at 03:15 AM
"twizzle"? I think you're thinking of "swizzle" - but I thought that usually refers to mapping global address space pointers to local virtual address spaces, not the other way around (?).
Posted by: Cenji Neutra | September 14, 2006 at 05:23 PM
It seems the injection across sims with its slowdown or complexity is due to the native measures of datatypes and the methods to gather them into a packet. The problem is simple, it is an attempt to use a CIL that has been further compiled natively for its final execution. As a CIL is intermediate, the process needs to return back to the intermediate state with current stack and data before transfer of the packet. That wouldn't need to be done if the original CIL is not discarded. The original CIL provides the appropriate indexes an data maps, which is what is tried to be reconstructed as described in the blog. Avoid the reconstruction steps and keep the original copy as a map, anotherwords.
On microthreading... moving away from one thread per process - good. However, it sounds risky with any need to rewrite code on the fly and harder to debug. Again with above ideas of the original CIL, having the maps would also help context switches. It is a little extra memory overhead but with the feature of much greater speed improvement. Once a packet can be made for like transfering sims, a similar packet can be context switched. The difference between the packet transfer and a context switch is that you don't need to check dependencies in a context switch, and you can expect memory structures already exist for each index in the maps - very fast in actual sims.
Just sharing some trade practices...
Posted by: Dzonatas | October 01, 2006 at 06:12 PM
best penis enlargement pill http://www.marviva.org/chs-bin/msboard.cgi?ID=SOLONAUTICA&msg=56498 - - fda approved penis enlargement pill
natural penis enlargement pill http://www.marviva.org/chs-bin/msboard.cgi?ID=SOLONAUTICA&msg=56498 - - australia enlargement penis pill
penis enlargement pill review http://www.marviva.org/chs-bin/msboard.cgi?ID=SOLONAUTICA&msg=56498 - - best penis enlargement pill
do penis enlargement pill work http://www.marviva.org/chs-bin/msboard.cgi?ID=SOLONAUTICA&msg=56498 - - penis growth pill
http://www.marviva.org/chs-bin/msboard.cgi?ID=SOLONAUTICA&msg=56498 - Penis Growth Patch Rx
Posted by: pinismanow | July 30, 2007 at 05:50 AM
Three phrases should be among the most common in our daily usage. They are: Thank you, I am grateful and I appreciate.
Posted by: penis stretcher | August 04, 2007 at 01:56 AM
That ad's interjection, was an inverse wavelet echo from some other interSIM perturbation?
Funny....
Posted by: cognicio merlin | August 09, 2007 at 04:34 AM
If you don't want to see this links, please email me dnsk_mail [ A t ] yahoo.com
And give URL of your site. Snxs.
Posted by: Stive Angelo | August 24, 2007 at 07:32 AM
Only click if you are 18 years or older!
http://newspage20.supper2007.com
http://newspage38.supper2007.com
http://newspage6.supper2007.com
http://newspage34.supper2007.com
http://newspage19.supper2007.com
http://newspage35.supper2007.com
http://newspage55.supper2007.com
http://newspage209.supper2007.com
http://newspage112.supper2007.com
http://newspage9.supper2007.com
http://newspage179.supper2007.com
http://newspage87.supper2007.com
http://newspage89.supper2007.com
http://newspage92.supper2007.com
http://newspage220.supper2007.com
http://newspage77.supper2007.com
http://newspage161.supper2007.com
http://newspage13.supper2007.com
http://newspage129.supper2007.com
http://newspage144.supper2007.com
http://newspage2.supper2007.com
http://newspage88.supper2007.com
http://newspage43.supper2007.com
http://newspage90.supper2007.com
http://newspage93.supper2007.com
http://newspage305.supper2007.com
http://newspage37.supper2007.com
http://newspage16.supper2007.com
http://newspage167.supper2007.com
http://newspage165.supper2007.com
http://newspage199.supper2007.com
http://newspage201.supper2007.com
http://newspage164.supper2007.com
http://newspage202.supper2007.com
http://newspage73.supper2007.com
http://newspage211.supper2007.com
http://newspage44.supper2007.com
http://newspage115.supper2007.com
http://newspage110.supper2007.com
http://newspage113.supper2007.com
http://newspage27.supper2007.com
http://newspage82.supper2007.com
http://newspage198.supper2007.com
http://newspage207.supper2007.com
http://newspage200.supper2007.com
http://newspage240.supper2007.com
http://newspage49.supper2007.com
http://newspage226.supper2007.com
http://newspage168.supper2007.com
http://newspage116.supper2007.com
http://newspage111.supper2007.com
http://newspage114.supper2007.com
http://newspage62.supper2007.com
http://newspage99.supper2007.com
http://newspage14.supper2007.com
http://newspage76.supper2007.com
http://newspage97.supper2007.com
http://newspage119.supper2007.com
http://newspage7.supper2007.com
http://newspage150.supper2007.com
http://newspage152.supper2007.com
http://newspage154.supper2007.com
http://newspage156.supper2007.com
http://newspage10.supper2007.com
http://newspage126.supper2007.com
http://newspage224.supper2007.com
http://newspage72.supper2007.com
http://newspage925.sterobok.info
http://newspage757.sterobok.info
http://newspage770.sterobok.info
http://newspage666.sterobok.info
http://newspage669.sterobok.info
http://newspage672.sterobok.info
http://newspage662.sterobok.info
http://newspage663.sterobok.info
http://newspage664.sterobok.info
http://newspage665.sterobok.info
http://newspage891.sterobok.info
http://newspage755.sterobok.info
http://newspage667.sterobok.info
http://newspage670.sterobok.info
http://newspage673.sterobok.info
http://newspage714.sterobok.info
http://newspage934.sterobok.info
http://newspage777.sterobok.info
http://newspage885.sterobok.info
http://newspage853.sterobok.info
http://newspage889.sterobok.info
http://newspage884.sterobok.info
http://newspage883.sterobok.info
http://newspage774.sterobok.info
http://newspage772.sterobok.info
http://newspage691.sterobok.info
http://newspage769.sterobok.info
http://newspage692.sterobok.info
http://newspage771.sterobok.info
http://newspage679.sterobok.info
http://newspage720.sterobok.info
http://newspage863.sterobok.info
http://newspage864.sterobok.info
http://newspage636.sterobok.info
http://newspage878.sterobok.info
http://newspage613.sterobok.info
http://newspage850.sterobok.info
http://newspage881.sterobok.info
http://newspage668.sterobok.info
http://newspage671.sterobok.info
http://newspage867.sterobok.info
http://newspage871.sterobok.info
http://newspage921.sterobok.info
http://newspage716.sterobok.info
http://newspage879.sterobok.info
http://newspage753.sterobok.info
http://newspage869.sterobok.info
http://newspage873.sterobok.info
http://newspage685.sterobok.info
http://newspage618.sterobok.info
http://newspage611.sterobok.info
http://newspage868.sterobok.info
http://newspage872.sterobok.info
http://newspage682.sterobok.info
http://newspage639.sterobok.info
http://newspage927.sterobok.info
http://newspage763.sterobok.info
http://newspage847.sterobok.info
http://newspage637.sterobok.info
http://newspage845.sterobok.info
http://newspage754.sterobok.info
http://newspage930.sterobok.info
http://newspage690.sterobok.info
http://newspage767.sterobok.info
http://newspage768.sterobok.info
http://newspage766.sterobok.info
http://newspage660.sterobok.info
http://newspage651.sterobok.info
http://newspage658.sterobok.info
http://newspage922.sterobok.info
http://newspage855.sterobok.info
http://newspage857.sterobok.info
http://newspage858.sterobok.info
http://newspage859.sterobok.info
http://newspage861.sterobok.info
http://newspage849.sterobok.info
http://newspage776.sterobok.info
http://newspage656.sterobok.info
http://newspage865.sterobok.info
http://newspage856.sterobok.info
http://newspage860.sterobok.info
http://newspage862.sterobok.info
http://newspage619.sterobok.info
http://newspage621.sterobok.info
http://newspage625.sterobok.info
http://newspage700.sterobok.info
http://newspage939.sterobok.info
http://newspage617.sterobok.info
http://newspage650.sterobok.info
http://newspage693.sterobok.info
Posted by: ronelos | August 31, 2007 at 02:08 AM
ao credits
Tales Of Pirates gold
Tales Of Pirates money
gaia online gold
gaia gold
gaia money
last chaos gold
last chaos money
hero online gold
hero online money
buy hero online money
hero online powerleveling
hero online power leveling
eve isk
Posted by: qq | September 05, 2007 at 11:34 PM
url=http://www.tbcgold.com/rs2-gold-1.html]runescape money[/url]
[url=http://www.tbcgold.com/rs2-money-gold-1_1135.html]runescape gold[/url]
[url=http://www.tbcgold.com/rs2-money-gold-1_1135.html]buy runescape money[/url]
[url=http://www.tbcgold.com/rs2-money-gold-1_1135.html]buy runescape gold[/url]
[url=http://www.tbcgold.com/rs2-money-gold-1_1135.html]buy rs money[/url]
[url=http://www.tbcgold.com/rs2-gold-1.html]runescape items[/url]
[url=http://www.tbcgold.com/rs2-accounts-gold-1_1136.html]runescape accounts[/url]
[url=http://www.tbcgold.com/rs2-gold-1.html]runescape power leveling[/url]
[url=http://www.tbcgold.com/maple-story-eu-gold-173.html]Maple Story mesos[/url]
[url=http://www.tbcgold.com/maple-story-eu-gold-173.html]MapleStory mesos[/url]
[url=http://www.tbcgold.com/maple-story-eu-gold-173.html]maple story meso[/url]
[url=http://www.tbcgold.com/maple-story-eu-gold-173.html]maplestory meso[/url]
[url=http://www.tbcgold.com/silkroad-online-gold-27.html]SilkRoad online gold[/url]
[url=http://www.tbcgold.com/rappelz-gold-23.html]rappelz rupees[/url]
[url=http://www.tbcgold.com/rappelz-gold-23.html]rappelz gold[/url]
[url=http://www.tbcgold.com/star-wars-galaxies-gold-28.html]star war galaxies credits[/url]
[url=http://www.tbcgold.com/star-wars-galaxies-gold-28.html]swg credits[/url]
[url=http://www.tbcgold.com/star-wars-galaxies-gold-28.html]swg credit[/url]
[url=http://www.tbcgold.com/archlord-gold-9.html]archlord gold[/url]
[url=http://www.tbcgold.com/archlord-gold-9.html]archlord money[/url]
[url=http://www.tbcgold.com/archlord-gold-9.html]buy archlord gold[/url]
[url=http://www.tbcgold.com/granado-espada-gold-1228.html]Granado Espada vis[/url]
[url=http://www.tbcgold.com/granado-espada-gold-1228.html]ge vis[/url]
[url=http://www.tbcgold.com/sword-of-the-new-world-gold-1227.html]Sword of the new world vis[/url]
[url=http://www.tbcgold.com/the-lord-of-the-ring-eu-gold-1140.html]lotro gold[/url]
[url=http://www.tbcgold.com/the-lord-of-the-ring-eu-gold-1140.html]lotro online gold[/url]
[url=http://www.tbcgold.com/the-lord-of-the-ring-eu-gold-1140.html]lord of the rings gold[/url]
[url=http://www.tbcgold.com/the-lord-of-the-ring-eu-gold-1140.html]lord of the rings online gold[/url]
[url=http://www.tbcgold.com/dofus-gold-10.html]dofus kamas[/url]
[url=http://www.tbcgold.com/dofus-gold-10.html]dofus gold[/url]
[url=http://www.tbcgold.com/dofus-gold-10.html]dofus money[/url]
[url=http://www.tbcgold.com/final-fantasy-xi-gold-11.html]ffxi gil[/url]
[url=http://www.tbcgold.com/final-fantasy-xi-gold-11.html]final tantasy xi gil[/url]
[url=http://www.tbcgold.com/guild-wars-gold-16.html]gold guild Platinsum[/url]
[url=http://www.tbcgold.com/guild-wars-gold-16.html]Guild Wars gold[/url]
[url=http://www.tbcgold.com/ever-quest-2-gold-1257.html]eq2 gold[/url]
[url=http://www.tbcgold.com/ever-quest-2-gold-1257.html]everquest 2 gold[/url]
[url=http://www.tbcgold.com/ever-quest-2-gold-1257.html]buy eq2 gold[/url]
[url=http://www.tbcgold.com/ever-quest-2-gold-1257.html]eq2 plat[/url]
[url=http://www.tbcgold.com/lineage-i-gold-18.html]lineage 1 adena[/url]
[url=http://www.tbcgold.com/lineage-i-gold-18.html]lineage 1 gold[/url]
[url=http://www.tbcgold.com/lineage-ii-gold-19.html]lineage 2 adena[/url]
[url=http://www.tbcgold.com/lineage-ii-gold-19.html]lineage 2 gold[/url]
[url=http://www.tbcgold.com/second-life-gold-26.html]second life lineden[/url]
[url=http://www.tbcgold.com/anarchy-online-gold-8.html]anarchy online money[/url]
[url=http://www.tbcgold.com/anarchy-online-gold-8.html]anarchy online gold[/url]
[url=http://www.tbcgold.com/anarchy-online-gold-8.html]ao credits[/url]
[url=http://www.tbcgold.com/tales-of-pirates-online-gold-1226.html]Tales Of Pirates gold[/url]
[url=http://www.tbcgold.com/tales-of-pirates-online-gold-1226.html]Tales Of Pirates money[/url]
[url=http://www.tbcgold.com/gaia-online-gold-12.html]gaia online gold[/url]
[url=http://www.tbcgold.com/gaia-online-gold-12.html]gaia gold[/url]
[url=http://www.tbcgold.com/gaia-online-gold-12.html]gaia money[/url]
[url=http://www.tbcgold.com/last-chaos-gold-17.html]last chaos gold[/url]
[url=http://www.tbcgold.com/last-chaos-gold-17.html]last chaos money[/url]
[url=http://www.tbcgold.com/hero-online-gold-15.html]hero online gold[/url]
[url=http://www.tbcgold.com/hero-online-gold-15.html]hero online money[/url]
[url=http://www.tbcgold.com/hero-online-gold-15.html]buy hero online money[/url]
[url=http://www.tbcgold.com/hero-online-gold-15.html]hero online powerleveling[/url]
[url=http://www.tbcgold.com/hero-online-gold-15.html]hero online power leveling[/url]
[url=http://www.tbcgold.com/eve-online-gold-7.html]eve isk[/url]
[url=http://www.tbcgold.com/eve-online-gold-7.html]eve online isk[/url]
Posted by: qq | September 05, 2007 at 11:35 PM
thanks for your sharing.sir!
so i share u some useful websites too.
http://www.buywowgold.org.cn wow gold|buy wow gold
http://www.buy-wow-gold.org.cn wow gold|buy wow gold
Posted by: cool dog | October 11, 2007 at 08:01 AM
thanks for your sharing.sir!
so i share u some useful websites too.
http://www.buywowgold.org.cn wow gold|buy wow gold
http://www.buy-wow-gold.org.cn wow gold|buy wow gold
http://ggtop.nbatop.com google排名|google左侧排名
http://www.nbatop.com nba live|nba live 2008
Posted by: cool dog | October 21, 2007 at 05:34 AM
Hello!
How are you?
Posted by: boleUsepe | October 26, 2007 at 05:13 AM
XRumer 4.0 is the perfect program for promotion!
It's have CAPTCHA recognizer, email verificator, and a lot of other functions...
But. I forgot link to it :(
Can you give me URL to the XRumer description? screenshots, etc.
Thank you
Posted by: XRumakTheBest | November 03, 2007 at 05:34 PM