27 October 2009

lag hoodoo number seven: the server

Early on I mentioned server-side lag as a potential issue. This, as you may recall, is reported on both the Lag Meter and, in much greater detail, the Statistics Bar. The most interesting server numbers on the Statistics Bar as far as I'm concerned are Time Dilation and Sim FPS. Other potentially interesting ones are Agent Updates/Sec and Script Events.

Time Dilation is a measure of how well the region is keeping up. Typically, it should be at 0.99. If it starts to drop below 0.95, the region is lagging, and the lower it drops, the worse the lag. Likewise, Sim FPS is a measure of the fastest rate the sim is able to update the scene to viewers; as with FPS on viewers, if it drops below 15 FPS, you will notice jerkiness, even if your viewer FPS is faster.

So what causes server side lag? The simple answer is complexity: the more there is for the server to deal with, the slower it gets. This complexity can be caused by lots of prims, lots of textures, lots of scripts, or lots of avatars. Starting with the last one first, the server has to keep track of the number of avatars, and the relations between those avatars and everything else in the sim (for our purposes, consider a sim and a region to be the same thing). As the number of avatars in a sim increases, the number of relationships increases exponentially, as all the avatars' viewers have to be updated with information about each avatar. This is why twenty avatars in a sim can seem so much laggier than simply twice ten.

Lots of prims can cause lots of lags, all else being equal. This is true not only of the prims that are a part of the scene, but also the prims that are worn by avatars in the form of hair, shoes, and other attachments. Now the viewer can also be lagged by lots of prims, but the server performs some smarts so as not to send prims that cannot be seen, either because they are completely hidden, or because they are too far away. But the server still has to account for every one of those prims. Likewise, every textures on those prims have to be accounted for, and transferred.

Finally, scripts can cause lag. It's important to know that scripts are handled at a lower priority than the actual rendering of the scene. That means that, if the server is too busy accounting for everything else, it may handle scripts slowly, or not at all. If scripts are running, and there are a lot of them, or one or two that are very processing intensive, they can also add to server side lag.

So, what to do, what to do? Obviously, if you own or have permissions in the region, you can do more than if you are merely a visitor, by reducing both the number of prims and the number of textures. One clever approach is to combine a number of related textures into one, and then using offsets and scaling to use only pieces of that texture on different prims. Likewise, care in the use of scripts can make a big difference. Additionally, laying things out so that not all prims are visible from all locations, while not necessarily helping the server in terms of the number of prims to be managed, will reduce both network and viewer lag.

If you cannot control these aspects of the sim, there are still things you can do. Reducing the number of prims and textures on your avatar can make a difference. This does not mean you have to go naked in a crowded place, but it does mean that careful choice of what you're wearing can make a difference. Avatar Rendering Cost, ARC, is an interesting, though not entirely accurate, means of determining the load your avatar is contributing. This is found from the Advanced menu (activated with Control-Alt-D), as Advanced->Rendering->Info Displays->Avatar Rendering Cost. This will display a number, the ARC, over the head of all avatars in range. Generally, the lower the better, especially in a lag situation. However, notice that the ARC on other avatars, as you move away from them, will drop. This is because at a distance there is less to render on your viewer; but it is still having to be tracked by the sim. Experiment with different hair, or jewelry.

A naked avatar has an ARC of zero, but so does a fully dressed avatar, if she is only wearing appearance (non-prim) clothes and hair. It's the attachment of prims that drives ARC up, and, as we know, prims add complexity to the job the server has to do.

However, it is very important to remember, before you decide to become an ARC enforcers, yelling at others to reduce theirs, that ARC is often really a fairly minor issue compared to the physical presence of the avatar. So the main point in this is to mind your own avatar, and make sure you are not contributing more than necessary to the lag. Also, I recommend you not leave the ARC turned on, as it causes viewer lag for you.

Finally, be a good citizen and don't leave litter around. If you unbox something, don't leave the box lying around. If you pull something out from inventory, or create something for temporary use, remove it when finished.

2 comments:

Hyang Zhao said...

resize scripts must die

Tara said...

Or be better written. Are you seeing resize scripts as a big source of lag? I haven't looked at any of them up close; I mostly ignore them.