Combatting Script Lag

One of the major things that affects the performance of any sim, including Happy Clam Island is scripts. At HCI we want our visitors and renters to have a pleasurable experience. In order to do this, it's up to everyone who has the ability to place objects anywhere on the sim to help combat lag; particularly script lag.

Scripts are the real essence of Second Life; without them, SL would be a pretty boring, featureless place. But a lot of scripts in objects are really unnecessary and only serve to contribute to that ephemeral quality of low usability known as lag.

From Second Life Insider:

Script Time is […] usually the largest factor. This is how much time the sim spends paying attention to scripts. Not necessarily actually running them, but managing their memory, processing potential events for them, determining if a listening script has heard something, and all of that. There's no hard and fast rules for reducing the lag in scripts. Some busy scripts with lots of timers, sensors and listens have very low impact on overall simulator lag, while some very simple scripts that take pains to avoid these can be utter lag monsters. When it comes to lag, it's more about art and experience rather than simple rules like 'no listens' or 'no sensors' or 'no timers'. Each of these systems can be used well — or used badly.

Finding Scripts That Cause Lag

If you're lucky enough to be an estate manager, you can use the Region Tools to find the top scripts in the region. Go to

Is there a way to export this information to a file or to query it using an external application? If not, let's ask for one on the JIRA!

If you don't have the estate tools available to you, you can still find out which objects are on your land by going to the About Land box:

<picture>

While not quite as helpful in identifying scripts, it is a good way to show exactly what you've got on your land.

Which Scripts Are Not Needed?

Scripts which are simply setting a 'sticky' prim property, such as:

  • Prim Size
  • Float Text
  • Target Omega (spin)
  • Texture map or color
  • Particle emitters

Of course, if any of these things need to change automatically (i.e. as a response to external stimulus) during the lifetime of the object, you'll need to keep the script in there. But things that simply sit and spin, like my DNA plant, or things that need float text set once and then can be forgotten about, like my freebie box, can either have their scripts removed or (better yet, if you might want to change them again in future) have their scripts disabled.

EXTERMINATE!

You don't need to go around ripping the guts out of your objects (unless you know you'll never need that script again). The kinder, gentler way is to simply disable the script. Now, if I was Torley Linden at this point I'd have a video. I'm not, so a few pictures will have to suffice.

First, pick the object you want to victimise. Right-click on it and select "Edit" from the pie menu:

pie-menu

Go to the object's "Content" tab:

object-contents

Right-click on the script you want to disable and select "Open":

script-open

The script window opens. Don't worry if you don't have modify rights to the script; you can still change it's running state. The "Running" checkbox (circled in red in the picture below) at the bottom left of the script window is checked when the script is running and unchecked when it's not. Simply uncheck that box and the script is now no longer contributing to lag:

script-window

Now all you need to do is "Rinse and repeat"!

Other Things You Can Do

The Region Performance Improvement Guide gives some other tips on reducing lag, notably:

  • Reduce the size of textures on your objects - try to keep them to 512x512 pixels where possible
  • Reduce the number of prims used - always be prim-aware! This will also allow you to have more "stuff" on your land if you try have as few prims as possible per object.
  • Try not to use megaprims - not always possible; but they do induce lag
  • Try not to use sculpted prims - of course! There's an extra bitmap for the region to handle and the viewer to download here…
  • Try not to use particles - I'm looking at you, Nostrum Forder!

Good Coding Techniques

Although this is primarily a tutorial for people who are simply placing objects on their land, it's worthwhile pointing out a few tricks to keep lag low if you're writing scripts.

This LSL Wiki page really says all you need to know about reducing lag in your own code, so I'm not going to repeat that here; there's a lot of good advice on that page; it should be required reading for anyone starting to script with LSL

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License