Fixing slow scripts

Creating scripts
User avatar
Dot Matrix
Posts: 1625
Joined: Sun Jul 28, 2013 3:26 am
Has thanked: 1208 times
Been thanked: 2324 times

Fixing slow scripts

Post by Dot Matrix »

Today's update included tools to find slow scripts: New Tools for Fixing Slow Scripts

When I listed the slowest scripts, the chief culprits were clocks and chandeliers. I really would like to keep one of the clocks working (it played a part in a past story). I guess the slow scripts might be in the clock hands. How might these be optimised?

Thanks in advance...
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1141 times

Re: Fixing slow scripts

Post by Graham Mills »

I need to make something clock-related so I'd be interested in having a look at the scripts if they're open source.
Dot Matrix wrote:Today's update included tools to find slow scripts: New Tools for Fixing Slow Scripts

When I listed the slowest scripts, the chief culprits were clocks and chandeliers. I really would like to keep one of the clocks working (it played a part in a past story). I guess the slow scripts might be in the clock hands. How might these be optimised?

Thanks in advance...
User avatar
Marstol Nitely
Posts: 480
Joined: Mon Dec 24, 2012 1:42 am
Has thanked: 1019 times
Been thanked: 432 times

Re: Fixing slow scripts

Post by Marstol Nitely »

Hi Dot,
Not sure if you are talking about grandfather clock that was purchased from Nitelys or the chandelier I gave you, but with the help of Ilan and Oren's new tools I did some investigating. The scripts I use in my clocks for the clock faces are open source and are running surprisingly well. Their script time is "0". Don't know that you can get much better than that.

Unfortunately, The scripts for the pendulum and door on the grandfather clock are not running so frugally. The door goes up to 35.697 when it is opened or closed, but then goes back down to zero. Not sure how big of a problem this is since it only occurs when opening or closing? The pendulum is a big problem, when set to run it was running between 14.250 and 21.393.

I'm assuming you are referring to the chandelier I gave you and yes when running the flame, it is way too high! My test showed between 14.250 and 21.429. And what fun is a chandelier without a flame?

I'm going to try to find a solution for the pendulum and the flames and send my customers an update if I can resolve the issue. In the meantime, I'll temporarily (I hope) take these items off the market.

@Graham. The clock script with "0" script time is available for free at Marcat on the second floor of the boutique if you'd like to pick one. Or IM me and I'll drop one to you when I'm online next.
These users thanked the author Marstol Nitely for the post (total 2):
Alexina ProctorDot Matrix
Graham Mills
Posts: 1314
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 1134 times
Been thanked: 1141 times

Re: Fixing slow scripts

Post by Graham Mills »

All fire, i.e. particle, scripts seem to have a high value but I guess you can disable them if the flame is always on.

PS @Marstol Thanks, I'll check it out.
Last edited by Graham Mills on Thu Aug 06, 2015 9:19 am, edited 1 time in total.
User avatar
Marstol Nitely
Posts: 480
Joined: Mon Dec 24, 2012 1:42 am
Has thanked: 1019 times
Been thanked: 432 times

Re: Fixing slow scripts

Post by Marstol Nitely »

The Nitely chandeliers can be turned on and off, so maybe a disclosure about the script time and a suggestion to keep them off when not in use? Not sure what I'll do, but I've taken them off the market for now.
User avatar
Dot Matrix
Posts: 1625
Joined: Sun Jul 28, 2013 3:26 am
Has thanked: 1208 times
Been thanked: 2324 times

Re: Fixing slow scripts

Post by Dot Matrix »

Thanks for your helpful replies. :)

Marstol, the clock that was particularly eating script time wasn't one of yours, but that's useful to know about the clock scripts you used, and thank you for making them available.

I really like your chandelier; it's elegant and attractive, and I was using it in Vespers Lodge and in the little church on Intersections. But you are right, it was a culprit so I have temporarily put it away in inventory.
These users thanked the author Dot Matrix for the post (total 2):
Marstol NitelyAlexina Proctor
User avatar
Kayaker Magic
Posts: 354
Joined: Sun Dec 01, 2013 8:40 am
Has thanked: 52 times
Been thanked: 393 times

Re: Fixing slow scripts

Post by Kayaker Magic »

In my experience, the most common reason for large Top Scripts scores is calling llSleep, llSetPrimitiveParams, llAdjustSoundVolume or ANY OTHER ROUTINE that has a forced delay. If your clock script is using llSetLinkPrimitiveParams to move the hands, change it to llSetLinkPrimitiveParamsFast and I'll bet you see your Top Scripts score go down my at least two orders of magnitude.

Unfortunately, these high scores from forced delays do not actually indicate that your script is using lots of CPU. Ilan verified this for me today when I got the Top Scripts score on my surfing waves to go from 3000 down to 3 ms /30 seconds (THREE ORDERS OF MAGNITUDE!). Ilan looked at the server statistics and my CPU usage did not go down at all, even with this huge drop in Top Script scores. The reason is that the entire time your script is in a forced delay is counted towards top scripts, even though your script is not running and not using the CPU during this time. It is locking up other important resources, so you want to fix this for several other reasons anyway:

1) Ilan will stop beating you about the head and shoulders about how THAT script is using up too much CPU.
2) Your customers will stop beating you about the head and shoulders about your inefficient scripts.
3) Forced delays (or ones done on purpose with llSleep) lock up a "script thread", a very important simulator resource. You do not want to see what happens if the simulator runs out of script threads.

I have written about this forced delay problem before: viewtopic.php?f=26&t=1149

Changing calls from llSetLinkedPrimitiveParams to llSetLinkedPrimitiveParamsFast is easy, working around some of the other functions is more difficult. It is most difficult to switch from using llSleep to using llSetTimerEvents, but I think this should be done.

I have done several optimization passes over the surfing wave script and was puzzled why it continued to get such a high score on Top Scripts. It turned out that I forgot there were 5 little tiny scripts in child prims that made wave hissing and crashing noises. These scripts called llAdjustSoundVolume once a second to make the wave get louder as it approached the beach. I did not realize that llAdjustSoundVolume has a 0.1 second forced delay until today! That is 100ms * 30 seconds * 5 scripts which is a big chunk of bad top scripts score. I re-wrote the script to play a sound that was pre-recorded to increase in volume, then based on a llSetTimerEvent switched to looping a sound at fixed volume, then switched to playing a sound that fades at the end. Fortunately in water hiss sounds, you don't hear a click when you switch from playing one to another.
These users thanked the author Kayaker Magic for the post (total 3):
Dot MatrixAlexina ProctorMarstol Nitely
User avatar
Kayaker Magic
Posts: 354
Joined: Sun Dec 01, 2013 8:40 am
Has thanked: 52 times
Been thanked: 393 times

Puzzling slow script score on surfboards

Post by Kayaker Magic »

I have a bunch of demo surfboards, kayaks and boats lying around on Panthalassa for people to try out. They all get Top Script scores in the 30 to 60ms range when they are sitting around doing nothing. They should be getting 0 (zero)! If I could fix this, it would lower my Top Scripts score by another big chunk, because there are so many vehicles sitting around.

I put in diagnostics and verified that the timer event is turned off when the surfboard is sitting on the beach. I even checked to see if I left a not_at_target event running. Nope, nothing is ticking. I can't figure out why the scores are so high. (Before the changes to Top Scripts these were getting scores in the 0.02ms range and I just ignored numbers that small).

Any ideas why this is happening to my surfboards? Any thoughts on where to look?
User avatar
Dot Matrix
Posts: 1625
Joined: Sun Jul 28, 2013 3:26 am
Has thanked: 1208 times
Been thanked: 2324 times

Re: Fixing slow scripts

Post by Dot Matrix »

I've a couple of your ocean-going canoes out in Intersections (I like them very much too) -- they don't register at all on the "Top Scripts" list. In fact, only one object is showing now on that list, scoring a total of 8 ms.
User avatar
Oren Hurvitz
Posts: 361
Joined: Sun Dec 23, 2012 8:42 am
Has thanked: 19 times
Been thanked: 499 times
Contact:

Re: Fixing slow scripts

Post by Oren Hurvitz »

UPDATE: following some useful feedback, we changed the way we count script times. There are several changes, so some scripts will now show up as taking more time, and some less. In particular, sleep time is no longer counted as part of the script time, since it doesn't use the CPU (thanks to Kayaker Magic for pointing that out).

So after yesterday's excitement of checking your scripts, please look at them again... the results could be much different.
These users thanked the author Oren Hurvitz for the post (total 3):
Marstol NitelyDot MatrixHandy Low
Post Reply