Region Optimizing 101
We’ve been getting a few complaints lately from some users about region performance and after investigating we have found the common issue to be either too many large textures, mesh which is too “Meshy”, scripts which are far too laggy, or a combination.
Before we begin, it’s important to understand what happens when you land in or cross into a region.
As soon as you enter a region, the viewer requests the server to send all content within it’s view. This includes mesh items, prim items, and all textures.
If 10 users arrive in a region in a similar spot, then 10 users have to download the same content.
Not only do you each have to download the content present in the region, but you also have to download the textures and items on each avatar.
Some users attach all sorts of things to their avatars and dress them up with many different items. The “Data” for each of these items has to be sent to all other users in the region.
I’ve seen some avatars wearing prim hair which uses more than 10k prims, each having a texture of 512×512 and sometimes they are using 1024×1024 textures.
I’ve seen some avatars wearing scripted items which can contain 20-30 scripts or more.
Performance in a region is a trade-off. The best performing region would have no content at all. A poor performing region would be one which is loaded to the prim limits with objects using large textures, lots of high complexity mesh items, and poorly written scripts taking up too much script time.
There really isn’t a “Model” for a great performing region as each user has to decide on the “Spot” where they have the visual appeal or “Look” they are after combined with the performance they can accept.
Since regions are rarely the same and user’s preferred level of performance differs from user to user, there is simply no way to define a good performing region.
We also have differences between users’ machines and their internet connections.
You may build up a region where things seem fine for you, but someone else with a lesser machine/video card may find your region horrible. Even similar machines may have different experiences due to the internet connection each user has bringing data into and receiving data from the DigiWorldz servers.
It’s easy to blame the region or the servers the region is on, but the truth is, more often than not, it’s the content users have in the region causing the issues.
Think of each region as a truck. Think of the content as the load inside the truck. This truck is designed to carry only a certain amount of load. As we add more load to our truck, performance begins to drop off. If we continue to pile on more and more load, eventually the truck will not perform at all.
Let’s go through each of these, one at a time and talk a bit about each:
First up, Texture sizes.
Textures are simply images we apply to the face of a prim or mesh to make it appear the way we want. Sometimes the texture has text on it, while other times it may have a gradient, and the alpha channel may be used. The common image type these days appears to be a .png due to the many textures which use the alpha channel.
Often times, we obtain textures from online resources, texture shops in our grid or in other grids, or we make them ourselves.
In OpenSim the largest texture we can upload is a 1024×1024 pixel image.
A “Typical”, “optimized” 1024×1024 pixel png image using an alpha channel would be approx. 350kb in size.
In the above example, a 1024 x 1024 png image using an alpha channel and having an approx. file size of 350kb is being used on a sign of some sort. Now, let’s imagine 10 avatars landing in the region; this means 10 avatars need to load this image so now the total data we need to send out from the region is 3500kb.. or approx. 3.5mb. Not so bad, right?
Now, let’s imagine a region which has just 2000 prims, each with a different textures of 1024 x 1024 and using an alpha channel with a file size of 350kb and 10 avatars land in the region. We suddenly have to send out 2000x350kb = 7,000,000kb to 10 avatars.. so 10 x 7,000,000 = 70,000,000kb, or 68359.38mb of data (68GB!!).
How much data would need to be sent if we have 5k prims with the same texture being sent to 10 avatars?
Typically, a 1024 x 1024 texture is approx. 4 times the size as a 512×512 texture.. if instead of the 1024 texture we used the 512.. we would have to send 4 times less data. A 256×256 texture is 4 times smaller than a 512×512.. etc, etc.
The point here is everyone thinks using a 1024 texture will give them the best looking object. While this is true in some case, in most cases using a 512×512 or smaller texture is just fine and you wouldn’t see a difference unless you were up very close to the object.
I have seen small objects like jewelry using 1024×1024 textures. I have seen small “Beach Chairs” using the same. I have seen small stepping stones using the same. This is simply wasteful of the resources in the region as these items could use small textures and still provide the very same “Look” the user is after.
The problem is, either the users doesn’t know any better, or they fail to recognize they are using such large textures.
Every user should always ask themselves the question.. can my item use a smaller texture?? If the answer is yes.. then use a smaller texture.. if the answer is no, then use a large texture… if the answer is “I don’t know”.. then do a few tests to see what the smallest size texture you can use would be and use that.
Sure, it takes a bit of time to either find, produce, or resize textures to the size you need, but the performance increase you will realize is more than worth it.
Be sure to always let others know the same.. the more people we can educate on this issue, the better off we will all be.
Next up, Mesh Items…
First rule.. if you can use a prim to do the job.. use it instead.
Mesh items are made up of triangles. Some objects might have very few, while others have many.
The more triangles a mesh has, the bigger it is (file size) the time it takes to download the data will take longer and the more work your video card has to do to display it.
Just like textures, often times you can use a mesh of the same “Physical” size but with less triangles and still achieve the same “Look” you are after.
Often times, the mesh items found in SL and in OpenSim have been downloaded from websites which offer up free, or low priced mesh models. More often than not, these mesh models are not optimized for OpenSim. Sometimes these mesh models have far more triangles than needed so that the person downloading can optimize to their standards, but many who download these models rarely ever change them.
I have seen small “Pillows” which are using “Thousands” of triangles… I have seen small beach towels using thousands of triangles. I could go on and on, but the point is, as a consumer of mesh items, you should always be aware of the number of triangles of the mesh you are attempting to use. The more triangles mesh has, the less performance you will realize while using it.
Don’t forget, mesh items avatars “Wear” also matter. Wearing mesh items with large amounts of triangles will result in slower teleports, poorer performance when attending events, etc.
It would seem all users want the best looking “Mesh” avatars… but the problem is, these mesh avatars are often resource hogs. If you have 20 avatars in a region using hi triangle mesh on their avatars, everyone in the region will pay part of the price in lower performance.
Always be aware of the number of triangles in the mesh items you are attempting to use. Always try to use the least amount of triangles in your region as you possibly can. The fewer the better… remember; the “Data” associated with each triangle has to be sent to each user in the region. If you have 200 plants with thousands of triangles in each plant.. and then you have 20 avatars in the regions.. things can get pretty ugly, very fast.
Mesh avatars: Yes they get they’re own paragraph. Generally each (human) mesh avatar is comprised of 20 pieces of mesh. Each of those pieces is holding a 1024×1024 texture. So, if you have even 4 of those on a region (now, we’re not talking hair, clothes, shoes etc on top of that – just the mesh avi itself), 4 avatars each with 20 textures that are 1024×1024… so 350kb x 80 = 28000kb which is 27.34gb… you can quite quickly bog down a person’s video card resources and ability to enjoy a region.
OpenSim does not have any “Safety” features which keep you from uploading and using things you really shouldn’t. OpenSim will let you upload mesh with thousands of triangles… it doesn’t care. But just as in the truck example above.. each triangle adds to the “Load” in the the truck.. the less it has to haul, the better the performance will be.
On to Scripted items..
Many users think the things they find on the hypergrid are good as long as they work. Many users don’t know anything about scripting and don’t care to know about scripting, but basic knowledge is a must if a user is going to be using scripted items.
Each scripted items takes a bit of “Time” in order to run through a cycle in the script. Often times the functions scripts use will cause the simulator to “Pause” for a short amount of time. This is by design in some functions and is normal. The problem is, if you have too many of these pauses, they add up and you see it as lag.
Scripted objects which use timers, url calls, or dataserver calls all cause a small bit of lag and there’s nothing we can do about that as it’s a normal function of how things work. The more scripted items you have in your region, the more time the script engine spends running through all of the script functions.
Each script has a “Time” associated with it. Each script’s “Time” will add to all other script times… for example, let’s say you have 10 scripts which use 1ms (.001 seconds) in order to function. If you have 100 of these objects than the total amount of “Script Time” the region is using is .001 x 100 = .1 seconds. If you have a script which uses 500ms to work.. if you have 10 of these then the total script time is 10 x .500 = 5 seconds.
I cannot tell you the number of times I’ve seen scripted items making requests to web sites for data.. the shoutcast boards are well known culprits of this.. They often try to contact a website several times within a 5 second time frame.. each request it makes induces lag.. many of these are not configured correctly and are trying to contact web pages which no longer exist resulting in 404 errors.. which induces even more lag.
Scripts which send emails are another large drain on performance..
If you open the estate tools you can choose the debug tab and then click on “Get Top Scripts” and you will see a listing of the top scripts in the region. This window will display the time each script is consuming and at the top of the window you will see a Total.. the goal would be to keep this to 1000ms or less.
Most users are surprised to find that sometimes just a few scripts will put them above this number. Again, it’s a balance.. you have to decide what level of performance will work for you.
Colliders: everytime you bump into an item that is not set to phantom, you are causing a collision event. Collisions, as they add up, cause lag. Any foliage, furniture, vehicles should all be set to phantom. Lights (the light beam from lights, specifically) should be set to phantom.
As you can see, there’s more to “Building” a region than just rezzing items you make or find elsewhere.
As a region owner, you should always be mindful of the impact an item will make in the performance of your region and build your region based on the level of performance you want to achieve. Remember, just because OpenSim will allow you to rez something, or upload something doesn’t mean it’s a great idea to use it.
Always remember, there are some great creators out there who are mindful of these issues and build their products with your best interests in mind (performance), while others are simply downloading items from websites and then uploading for use inside SL/opensim without regards to the impact these “Un-Optimized” items will have in the regions.
Always be “Mindful” of the “Load” you are placing into your “Truck”.. the more load you pile into it, the worse the performance… it’s up to you to determine what that level is for you… and you should be mindful that many users may have a less capable machine than you have… or a worse internet connection.
Just remember, building a region has more responsibility involved than just populating it with things you find or make.
One last bit of help.. not related to your region, but to your avatar.. check to be sure your avatar isn’t still listed as being in a group on another grid which no longer exists. If a grid no longer exists, get rid of the group.
Likewise, if you have friends on your friends list which were on grids which no longer exist.. delete the friends.
Each time you login or logout, the region tries to contact your friends on grids which no longer exist to let them know you’ve logged in or out.. since the grids no longer exist, neither do the friends so delete them instead of using resources to try to contact the forgotten grids.