Script performance/sim load questions... - SLUniverse Forums
 
Navigation » SLUniverse Forums > Development Discussion and Support > Scripting » Script performance/sim load questions...


Scripting Discuss scripting for SL and other platforms

Sponsor:
Vengeance Studio
Reply
 
LinkBack Thread Tools Display Modes
Old 06-20-2009, 07:20 PM   #1 (permalink)
Junior Member
 
Cynebald Ceawlin's Avatar
Reticulating splines
 
Join Date: Oct 2008
Location: In the middle
Posts: 4
My Mood:
SL Join Date: 3/16/2007
Business: The Mathom House
Script performance/sim load questions...

My partner recently asked me for a script to gradually cycle the color on a prim between 2 - 3 preset points. Easy enough, thinks me -- slapped something together to do just that, linearly interpolating the RGB values between specified colors. I went to double-check that I wasn't creating a hideous beasty that would bring sims to their knees, and found incredibly surprising results. While not a sim-killer by itself, it was chewing up nearly a millesecond (not something I'd care to set free in the wild). I was particularly surprised at this since I'm using nearly identical code to alpha-fade textures in and out on a picture frame, which (when fading in or out) comes in at around 0.02 ms. The biggest difference in the fade loops are that the alpha fader computes an exponential (llPow) whereas the color fader does a vector addition, and the alpha fader calls llSetAlpha() while the color fader, of course, calls llSetColor().

There are some other (perhaps significant) structual differences, of course -- I've set off to investigate them, but I'm finding I'm getting oddly inconsistent numbers from the Top Scripts window which is making it very hard to figure out what's going on. So, I thought I'd defer to the experts here, and ask a few questions...

First off -- the "meat" of the code, where the script spends the VAST majority of its time:
for (i=0; i<g_nFadeSteps; i++)
{
llSetColor(vCurColor, ALL_SIDES);
vCurColor = vCurColor + vColorStep;
llSleep(fFadeDelay);
}
(I of course set up vCurColor and vColorStep vectors as appropriate above the for loop.)

1) I'm seeing WILDLY different numbers with the script compiled to LSL vs. Mono... with Mono coming in MUCH higher. I saw similar things way back around the introduction of Mono, but haven't seen that since. Anybody have any thoughts/info on this?
2) Compiled to LSL -- it doesn't show up in the top scripts for some time; disappears again if I recompile or stop/start the script. When it first shows up, it comes in around 0.05, but will build up over time to approach 1 ms; it will then occasionally drop back down to the neighborhood of 0.15. Some kind of wierd memory/garbage collection craziness with the vectors? Something bizarre happening w/ repeated calls to llSetColor?
3) Is llSetColor inherently more expensive than llSetAlpha? I wouldn't expect the vector add and llSetColor call to be worse than llPow(), a (scalar) subraction, and call to llSetAlpha() but I don't know the guts well enough to know.
4) I'm running the color fader in an infinite while loop in state_entry(), whereas the alpha fader is running in a timer (timing comparisons done w/ timer frequency set to make it fire back-to-back, i.e. achieve much the same effect as the while loop). Something bad about not letting state_entry() complete? I thought letting the while loop keep running would be better/lower impact than having timer events going off all the time -- am I out to lunch on this?
5) Anybody have better tools than Top Scripts for looking at script performance/sim loading? I work hard to keep my scripts use of sim resources to an absolute minimum (both memory and instruction/s) but my confidence in that as a reliable tool is being shaken by the erratic results I'm getting on this script...
Cynebald Ceawlin is offline   Reply With Quote
Old 06-20-2009, 08:34 PM   #2 (permalink)
Senior Member
 
NeoBokrug Elytis's Avatar
 
Join Date: Sep 2007
Posts: 409
My Mood:
SL Join Date: 11/01/2005
Business: The Wastelands
Top scripts in estate tools is inaccurate.
NeoBokrug Elytis is offline   Reply With Quote
Old 06-20-2009, 08:53 PM   #3 (permalink)
Junior Member
 
Cynebald Ceawlin's Avatar
Reticulating splines
 
Join Date: Oct 2008
Location: In the middle
Posts: 4
My Mood:
SL Join Date: 3/16/2007
Business: The Mathom House
Thanks, Neo -- so I was beginning to deduce, based on what I've been seeing. I've known for a while it gave dubious results, but I hadn't seen anything like this until checking on this little script. Makes it kinda difficult to be a responsible scripter who pays attention to how his scripts impact sims!!!
Cynebald Ceawlin is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On