How to Optimize Performance?


Snoopy Pfeffer's picture

By Snoopy Pfeffer - Posted on 30 January 2012

Kinds of Performance Issues

When using OpenSim you might experience the following three kinds of performance issues, causing so called lag:

  • Viewer lag  (client lag)
  • Network lag
  • Server lag

Lag can cause low picture frame rates, avatar movements getting delayed or even not stopping, avatars do not rez properly and in extreme cases even the viewer might crash.

In the following sections we describe how to identify these different performance problems, what causes these issues and how to fix them.

Problem Analysis

Lag Meter

Open the menu Help > Lag Meter. You will see traffic light colors for viewer (client), network and server lag. Usually all three colors should be green. If you see yellow or red colors, you probably have performance issues in the corresponding area.

Statistics Bar

For a more detailed analysis open the Statistics Bar window, using the menu View > Statistics Bar. In the Basic and Simulator section of the Statistics Bar window check the following values:

  • Basic: FPS    Should be at least 15 fps, better are 30 fps or higher; otherwise viewer lag
  • Basic: Bandwidth:   A high value indicates that objects are still being loaded and rezzed
  • Basic: Packet Loss    Should be 0.0%; otherwise network lag
  • Basic: Ping Sim    Should be lower than 300 msec; otherwise network lag
  • Advanced: Sim FPS    Should be at least 40 or higher; otherwise server lag (maybe script engine)
  • Advanced: Physics FPS    Should be at least 40 or higher; otherwise server lag (physics engine)

Continue to read the corresponding sections below.

Viewer Lag

Viewer (client) lag is usually caused by inappropriate viewer settings, causing a low picture frame rate (FPS). The reason is that your computer hardware and operating system are not able to handle the amount of data fast enough, for the viewer settings you have chosen.

Graphics Preferences

Open the preferences window with the menu Edit > Preferences and open the Graphics tab. Check the current settings and click the Recommended Settings button and then the OK button.

Open the Statistics Bar and check, if the FPS value is high enough again (more than at least 15 fps). If you still experience lag, open the Graphics tab again and slide the Performance slider further left. You can also check Advanced options and manipulate individual viewer settings to improve viewer performance. Reduce various levels of detail (high -> medium -> low), the number of particles shown and/or the draw distance.

Especially the draw distance is important for regions with high building density, using complex prims, sculpties or 3D mesh objects and/or many high resolution textures. Such regions require a much lower draw distance than normal regions to not cause viewer lag.

It is a good practice to build regions such that the contents in the visible distance is not too complex, because such regions anyway cause problems with high visitor traffic. The reason is that every new user has to load and rez the contents in draw distance range. This causes high network traffic for a longer time (see duration of high Bandwidth values in the Statistics Bar, when you enter the region with an empty viewer cache).

This means viewer lag can also be caused be the kind of contents of your region. Anyway you can simply reduce the draw distance until the frame rate is at an acceptable value.

Network Lag

When you experience network lag, check your network connection. Especially be sure not to use a wireless network connection (WLAN). Check if other users overload your Internet connection, for example by using bandwidth intensive file sharing or multimedia applications.

If you have knowledge of network technology and tools, use ping and traceroute to the OpenSim region server to identify where in the network packet loss or delay suddenly increases. Then contact the owner of that network device to fix that network issue. Sometimes a simple restart of that network device fixes such problems. In other cases faulty configuration changes or hardware problems are the reason.

Server Lag

In the previous analysis you could already identify if the server lag is caused by physics engine overload (low Physics FPS) or by some other server related issues (low Sim FPS; usually caused by the script engine).

Open the Estate Management window, Debug tab, using the menu World > Region/Estate. If you are not the estate owner of that region, you first need to request the admin status by using Advanced > Admin Options > Request Admin Status.

Get Top Colliders

High Physics Engine Load

If you experience high physics engine load, click on Get Top Colliders. Click the Refresh button multiple times. After a while you should see just a small list with the physics objects causing most physics engine load. Look for objects with a Score of 100 or even much higher. Select such an object and then click the Show Beacon button. Go to that object and analyze why the physics engine load is so high and fix that problem.

If you recognize that physics objects outside of the region boundaries cause the high physics engine load, log into the Control Panel and open the Region Management Tool for that region. Click on Delete Objects select Outside Boundaries and then click the Execute button. This should immediately reduce physics engine load.

The appendix of this article contains general information how to reduce physics engine load.

High Script Engine Load

If some other reason causes a low Sim FPS value, the probablity is high, that high script engine load is the reason for the problems you experience. Click on Get Top Scripts. Click the Refresh button multiple times. After a while you should see just a small list with the scripted objects causing most script engine load. Look for objects with a Time of 50 or even much higher. Select such an object and then click the Show Beacon button. Go to that object and analyze why the script engine load is so high and fix that problem.

Typical reasons for high script engine load are loops in scripts, that cause intensive repetitive calculations, extensive sending of events or use of sensors that get triggered oftened (for example listening on channel 0).

 

 

Appendix - Reducing Physics Engine Load

Reasons for High Physics Engine Load

In the following situations the physics engine has to do calculations:

  • Movements of physical objects
    • unscripted physical objects (i.e. a ball)
    • scripted physical objects (i.e. vehicles implemented as physical objects)
  • Movements of avatars
    • avatar walking over terrain
    • avatar walking over a prim surface (normal prims or sculpties)
  • Collisions between non phantom objects and avatars
    • avatars colliding with each other
    • non phantom objects colliding
    • avatar colliding with a non phantom object

Many physical movements require the detection of collisions. Collisions are detected based on so called Bounding Boxes, rectangular boxes using the X, Y and Z axis and that contain the whole object, avatar or segment of terrain.

You can toggle displaying these internal Bounding Boxes in the viewer using the menu Advanced > Rendering > Info Displays > BBoxes

Bounding Boxes

How to Reduce Physics Engine Load?

To reduce physics engine load you should do the following:

  • Try to avoid physical objects (i.e. use vehicles that are not physical objects)
  • Never create huge physical objects, because they easily cause many collision events
  • Make objects phantom, if possible (collision detection ignores phantom objects)
  • Make moving/rotating objects phantom
  • Use llTargetOmega and llSetTextureAnim for viewer side rotations/animations
  • Do not use hollow prims with the intention to let other objects or avatars move inside
  • Do not use too complex, rough sculpty prims and terrains as walking surface for avatars

Avoid collisions of Bounding Boxes as much as possible, to reduce physics engine load.

For example a hollow prim with a scripted vehicle constantly moving inside can cause high physics engine load.

By the way, lowering physics engine load is the main reason why avatar attachments are always phantom objects.