Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Inlining Optimizations in LSL Plus

Pike Trautman
Abstraction
Join date: 8 Dec 2006
Posts: 28
02-03-2009 19:20
An FYI to anyone who uses the LSL Plus IDE (or wants to)...
The LSL Plus IDE (0.10.0) has added support for inlining and some other optimizations (constant folding, mostly) for scripts. The basic idea is you edit, test, and otherwise manage your code out-of-world, but use the optimized scripts in-world. If you find a problem with a script in-world, you edit the source script, recompile out-of-world, and reupload. A sample:

Source script (maintained in your IDE):

float miles2feet = 5280.0;
float meters2feet = 3.2808399;
// pragma inline
float pythagorean(float a, float b) {
return llSqrt(a * a + b * b);
}

default {
state_entry() {
llOwnerSay((string)(pythagorean(6000.0,3000.0) / miles2feet));
vector v = llGetPos();
llOwnerSay((string)(pythagorean(v.x * meters2feet, v.y * meters2feet) / miles2feet));
}
}

'Compiled' script, with various optimizations.

// LSL script generated: Tue Feb 3 22:01:51 Eastern Standard Time 2009
default {
state_entry() {
llOwnerSay("1.270493";);
vector v = llGetPos();
float a = (v.x * 3.2808399200439453);
float b = (v.y * 3.2808399200439453);
llOwnerSay(((string)(llSqrt(((a * a) + (b * b))) / 5280.0)));
}
}

The inlining optimization is controlled with the 'pragma inline' notation placed before the function you want to have inlined. This feature interacts well with the LSL Plus module system: you can place many, short, useful functions into a common module, annotate them with the inline pragma, and then use them throughout your scripts, knowing that the call overhead will be optimized away.

The Windows and Linux versions of LSL Plus are ready now, the Mac version is pending...


http://lslplus.sourceforge.net
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-03-2009 19:57
YOu haven't said where to get it. URL? :D
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Pike Trautman
Abstraction
Join date: 8 Dec 2006
Posts: 28
02-03-2009 20:05
Ahh, I assumed it was a household name already... :)

http://lslplus.sourceforge.net
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-03-2009 21:09
Can it work standalone, from Make, or is it purely an Eclipse plugin?

I'm oldschool.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Pike Trautman
Abstraction
Join date: 8 Dec 2006
Posts: 28
02-04-2009 04:18
The 'compiler' is a standalone executable, though it isn't documented for standalone use...

you can download it here:

http://hackage.haskell.org/cgi-bin/hackage-scripts/package/LslPlus
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-04-2009 06:21
Lotta dependencies. :eek:

Might be easier to write my own using lscript_compile/indra.[ly].
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Pike Trautman
Abstraction
Join date: 8 Dec 2006
Posts: 28
02-04-2009 16:18
From: Argent Stonecutter
Lotta dependencies. :eek:

Might be easier to write my own using lscript_compile/indra.[ly].


Well, if you download the Eclipse plugin for your platform, there are zero dependencies. The executable is included.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-04-2009 17:50
Cor, guv, why didn't ya say so? :D
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore