[Opensim-users] Scripting: 10x speed boost with C#

Jeff Kelley opensim at pescadoo.net
Mon May 2 12:11:27 UTC 2011


At 4:36 AM +0100 4/25/11, Justin Clark-Casey wrote:

>Very interesting, Jeff.  The scripting engine in OpenSim transforms LSL to C#
>before compiling it so there wouldn't be a time difference due to
>interpretation.
>
>Of course, I'm presuming that you had configured all LSL scripting delays down
>to zero

No, because I was not aware of that option.

With ScriptDelayFactor = 0.0, the LSL version changes from an average of
2.15s to 2.10s. No big deal. The C# version is still around 0.2s.

I switched to C# because i noticed my script spent most of its time into
list handling (llList2Rot, which was a first speed gain over
4*llList2Float). Since LSL has no array structure, we use lists to emulate
them and waste a lot of time here.

Then, replacing llPow with System.Math.Pow gave me another speed boost.
Finally, replacing osSetPenColour, osDrawLine with direct drawlist
manipuations (drawList += ) accounted for the overall 10x speed increase.

Of course, that depends a lot on your application. If you are manipulating
prims, the gain may be near zero. If you do a lot of math and matrixes, it
may be higher.



More information about the Opensim-users mailing list