Saturday, 16 July 2011

The truth about lag and how to deal with it!

Anatomy of Lag

An incredibly informative post by Gwyneth Llewelyn, I didn't know a lot of the information in here and it really sheds light on what causes the different kinds of lag (server-side and client-side) and how to deal with them. Scripts aren't nearly as evil as people think. Ignore ARC altogether! You can get rid of that with your own settings. The only big and unavoidable contributor to event lag is how many people are there, moving about all over the place...

To summarise (as it's a long article)

*Scripts DO NOT cause lag*. No, really. They slow down other scripts though, so they're bad for vendors in particular. But they don't affect ANY other server- or client-side tasks, such as texture streaming (rez), chat, movement & physics, building, etc. etc. Main places to avoid large numbers of attachment scripts, then, are shopping malls (you don't want to affect the vendors!) clubs (likewise the dance animations) and places like scripted racetracks, combat zones etc. Anywhere that really depends on a certain sort of script to function properly. Don't forget you can set scripts in attachments to not running, if you don't want to delete them entirely (e.g. resizers). But to repeat, scripts only lag other scripts. If you don't use scripts, then you don't need to worry whatsoever about what other people are doing! Having said all that, I've now read the Phoenix wiki article on lag and that says that scripts DO lag sims. Well they can't BOTH be right :/ It's headache-inducing to have conflicting information like this and be expected to do the right thing by other SL users! Simplifications - "just delete all resize scripts" - don't help, because that isn't necessarily the best thing to do, if you want to be able to modify the item in future; but if you set scripts to not running, do they still cause problems? They are still counted by script counters.

Keep your draw distance as LOW as possible to see where you're going. The further you can see - which means the further your computer can see, not necessarily how far you are currently looking - the more textures you are requesting from the server, and that DOES cause lag. For everyone! At a crowded event (e.g. a fair) there will be huge lag in texture streaming even if everyone sits still, especially if people don't lower their draw distance. 20 high ARC, scripted, dancing bots cause less lag than 20 ARC=1, non-scripted, static people who are downloading textures from the server to their client. (For this reason, it is good to have enclosed shops with solid walls that stop you seeing anything outside a minimum draw distance of 64m. Alpha textures do NOT occlude, even if they appear opaque - IMO only idiots encode opaque textures with alpha. It's also good to economise on textures and only put them on the prim faces people actually see.)

MOVEMENT causes lag in two ways. 1) Sim lag, as it constantly updates avatar position. The more avatars, walking around, the more lag - sadly unavoidable at shopping events and especially fairs. (I'm assuming that if you use point-click tp, you will overcome this somewhat, as it only has to update one major positional change at a time instead of a series of steps.)*
2) Client-side - animations, *but not just from AOs* - ANY movement of the avatar, even the default pigeon waddle - at a big social event, it's better to try to keep still, ideally have everyone sitting in static poses or using synced movements (e.g. danceballs). AOs will probably not make a significant difference in the overall scheme of things, but this is why some events ask you to take them off. Spinning and jumping around on a default AO is as bad as wearing a complex fidgetty AO :p

*Of course here you have the trade-off of moving around the sim vs camming (with a high draw distance) and I don't know which is worse in terms of lag. Of course once you have downloaded all the textures, you can cam all you like without further affecting sim performance, so it's the initial *arrival* point of avatars that causes a lag spike. My guess is it would be best to come in with a low draw distance, wait a few moments on arrival to get local textures, then cam as much as possible, only moving on when you need to see (and download) a new area. Maps are helpful in this regard. Or, you could gradually increase your draw distance every few minutes - but sometimes you have to move, to see tiny prims and enable vendor scripts.

Local lighting will increase client lag as the illumination has to be calculated for each polygon as an avatar changes position. So unless you're trying to absorb the ambience and take beautiful snapshots, turning that off could help, particularly around people wearing facelights or under club spotlights. (I got this from the comments.) You can turn off shiny/bump mapping while you're at it, and also turn off advanced shaders (windlight settings). All those things make stuff look good but decrease client performance. Same with particles. If you don't need them because you're out shopping/hunting, turn them off. Other recommendations are to disable anisotropic filtering and anti-aliasing under Preferences → Graphics → Hardware Settings tab; and on Firestorm, disable http textures and VBO.

ARC is easily negated - instead of cussing at people with high ARC (avatar render cost) attachments, if you're suffering from client-side lag, you can easily overcome this by de-rendering everyone around you instead! Just go to your graphics preferences and turn on Avatar Impostors, setting the detail to low. Other people will simply stop rendering on your computer (if they are nearby, they'll look like an ugly set of polygons) and you won't have to worry about them any more. Incidentally, the high ARC on hair is mostly from tortured prims, probably not textures, since most of the hair will use the same 2-3 textures. You'll be getting a lot more texture streaming from the stores themselves. Also, the ARC counter is very inaccurate, and (as recently discovered) reported with a BIG difference on Firestorm. If someone yells at you for high ARC, first check if they are using Firestorm ;)

If need be, you can completely inhibit the rendering of other avatars under Advanced → Rendering Types → Avatar, but then you won't be able to see them at all and you might bump into people, which won't win you any brownie points, especially if you can move and they can't! You can also derender any one particularly annoying individual (or object) by right-clicking on them and selecting derender from the pie menu. I'm not sure if that's a good idea on some things which you might want to be able to see again in a different time/place, and I'd stick with the menu option which can be switched back easily.

Note that this page gives some slightly technical but not difficult advice on how to check that your preferred bandwidth settings are optimised for SL, which can also make a huge difference to performance, as you can have them set either too low or too high.

So if you really want to reduce lag for yourself: turn down draw distance, turn off advanced graphics settings and lower avatar imposter detail. Anything else is probably unavoidable and not fair to blame other people for. Simples! =)


  1. *imagines a Fledgeish meerkat and shakes head* actually that's a really useful heads up on things, thank you for finding all that stuff out... I'm still not really sure how it all works, I don't think I ever will be but it helps! TA