Monday, October 11, 2010

Scripts and Lag

I recently had a talk with EriX Oh of the Skybeam Estates. He wanted to discuss something many residents in Second Life don’t seem to be aware of: script lag.

Most residents are aware of the fact that more prims are around, the more lag there is, as each one takes a little bit of processing time. Scripts, however, also take time. So objects with scripts will create more lag than those without. EriX just shook his head at the mention of builders whom obsess with economizing their creations to have the fewest prims possible, yet stuff them full of redundant scripts.

“Many avatars with huge script-times/script-counts, they always tell me Linden Lab is the problem. I say to them they are the first problem. When I then ask the users to detach something or leave, they get angry. And even when I explain in detail, ... they still do not understand it.”

Of the subject on avatars and lag being written about more after the Avatar Rendering Cost (ARC) became available to view as an option, Erix commented, “That’s what many say, ‘Yes, but my ARC is low.’ That’s wrong. Scripts do not count in the ARC, and the ARC is only to detect local lag, not server lag. I must say my ARC may be high, but I’m not hogging the server (grin).”

As the manager of a sim, Erix had tools to help him see how much lag various objects created, sending me a couple pictures, “what you see here are all ‘ heavy loaded’ scripts .... - as this display is only limited to display ~100 scripts at one time. What you see here are times, how much time scripts need to execute.” By “heavy loaded,” he meant scripts particularly long and full of instructions, “and cause a lot of CPU load. The quantity of scripts does not matter if it lags or not, it’s the quality. What I look for often here ... generally speaking for an av, under 1 ms is okay, under 0.5 ms is perfect. When the sim has many scripts to execute, it all raises the times a bit. So on a full sim, I don’t care when I see avs under 1 ms.”

So when does script lag really begin? “Generally it’s a bit by bit feeling. You can’t say that avs over 1 ms are automatically ‘lagger: out!’ You need to think every av, even scriptless ones, cause CPU load on the sim. All objects with and without scripts cause lag. I look first at the sim itself. Are there many people? In a sandbox for instance, over 20 people around means it’s likely to lag. Who has objects with scripts? They cause lag. What I want to say, an avatar with more than 1 ms, is built wrong.”

Erix informed me that the fox avatar he uses most of the time is a modified copy of the original with redundant scripts removed, “removed over 300 scripts ... I’ll put on my original, and show you how ugly the times will be. You can potentially as one av lag a whole sim.” He then changed into his original av, which did seem a little slow to load. At first, the only difference seemed to be it’s use of invisiprims (EriX replaced them). Then he gave me a couple pictures of his sim statistics, and the difference was more obvious, :3.665 on an *idling* sim! Why that happened, if you look at me closely, you’ll see in *every* prim a script: Foxcolor. I counted them - 328 scripts!” These scripts were solely used for changing the color of his avatar fur. Since it was fully modifiable, after choosing a final color he removed all the scripts, “I also got rid of the original HUD, which I counted around 50 scripts.”

I mentioned some of my avatars had the option to change hair color. Erix answered, “Then they MAY have in every hair a script. May, because LL introduced a command in LSL to change child-prims from the root-prim on. So *one* script can change up to 255 child prims.” I changed to a "furry" skunk avatar with had a number of options which required some scripts, including changing hair color, as well as a radar, male AO, and flight feather. Erix looked at the statistics, “still under me (0.342), you’re 0.257. Nothing to worry about from my view.”

“A huge amount of scripts has other side effects. TPs often fail. And lagging, lagging, lagging. And because there's no quick, easy way to remove these scripts, I made a program, this: . Note that those who use the program: I'm NOT responsible for ANY damage.”

“So girls, with many hairs, check the script-counts, and remove them if not needed.”

We talked a little more, and soon parted ways, me knowing a little more about scripts and lag, and how a sim administrator saw it.

Bixyl Shuftan