• All submissions to this site are governed by Second Life Project Contribution Agreement. By submitting patches and other information using this site, you acknowledge that you have read, understood, and agreed to those terms.
Issue Details (XML | Word | Printable)

Key: VWR-2435
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Haravikk Mistral
Votes: 0
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
1. Second Life Viewer - VWR

Offloading physics to the viewer

Created: 13/Sep/07 07:33 AM   Updated: 30/Sep/09 01:31 PM
Return to search
Component/s: Avatar/Character, Performance
Affects Version/s: 1.22, 1.23
Fix Version/s: None

Issue Links:
Relates
 


 Description  « Hide
This idea is relatively simple:

Offload all 'non-critical' physics to the viewer to run in a separate thread. By non-critical I mean anything that can be calculated using information available to the client, that does not need to be calculated server-side for accuracy.

In essence this amounts to primarily moving your avatar. Since you already download the prims in a scene, it is then possible for you to calculate physics based on that data locally. All the sim needs to then know is where you think you are, and it can perform more lightweight checks for things such as land-permissions.

Using your location information the simulator simply has to route your position to other avatars.

To overcome the issue the of calculating physics on objects that you have not downloaded yet, the simulator would be broken up into blocks (if it isn't already, say 40m x 40m for the sake of argument). If your viewer hasn't fully downloaded the block your avatar is in, then it will request that the simulator calculate physics for you until further notice (ie when the area has finished downloading it can go client-side again).

For people who do not have multi-threading machines capable of handling the additional cost of calculating physics server-side, they could simply have the 'calculate my physics server-side' option switched on permanently, rather than having it enabled/disabled automatically as required.

ADVANTAGES

  • Less load on the server-side (especially on high-capacity sims, once someone rezzes enough it doesn't care)
  • More responsive/accurate physics on clients which can support this feature

DISADVANTAGES

  • Won't work properly for slower machines
  • Doesn't affect other physical objects, which can still cause lag if present in a sim


 All   Comments   Change History      Sort Order: Ascending order - Click to sort in descending order
Haravikk Mistral added a comment - 13/Sep/07 07:37 AM
As per this thread:
http://forums.secondlife.com/showthread.php?p=1674820#post1674820

An alternative is that avatar physics could be handled by an avatar farm. This would still offload physics for the avatar from individual simulators, but without placing it onto the viewer. This has the advantage of greater speed and security (no possibility of false values being sent*) but at the cost of requiring the extra hardware to run it.

  • while it would be possible to exploit this to move your avatar anywhere by using a custom-client, the server would still be responsible to checking your access to allowed/disallowed areas, no such features would be offloaded to the client except maybe to allow it to perform checks locally before a response from the simulator arrives

Lex Neva added a comment - 13/Sep/07 10:24 AM
I think the possible advantages are outweighed by the likely problems this would cause. I could see it becoming very common for your physics to get decoupled from the server's... everyone's connection is different. You'd be likely to have a different idea of where your avatar is than everyone else. If your client is actually telling the server where your avatar is, then slowness/bugs on your system will result in your avatar doing weird stuff in the view of everyone else. Lag on your end could result in people seeing you walking through walls. A hacked client could allow you to completely ignore, say, vertical walls. All in all, I think it's best to have one central authority for positions of avatars and their physics.

That said, though, some physics IS offloaded to the viewer: flexprims.


Lex Neva added a comment - 13/Sep/07 10:26 AM
...oh, and clothing ripple, too!

WarKirby Magojiro added a comment - 13/Sep/07 02:13 PM
I'm with lex on this matter.

Haravikk Mistral added a comment - 14/Sep/07 02:31 AM
Flex-prims are really only a visual candy though, they don't really do anything.

As for the latency issues; if you're lagging you already move strangely, in leaps or not at all, to you and to others. You also already see other avatars near you falling through things. At worst, this would require the server to do some processing on avatars who aren't sending updates as quickly as expected.

Think of it in a flow like this:
1. I press and hold the forward key
2. My client sends to the server that I am moving forward at X speed from Y position
3. The server does a simple check on this and sends to all other clients
4. Other clients now see me moving forward

At stage 3 the server simply checks to see how far I've deviated from where it expects me to be. If I've deviated too far then I'd be forced to balance between the position my client says it now is, and where I was last noted by the server.
For example. I'm <1, 2, 3> moving with a vector of <0, 4, 0> (4m/sec on the Y plane). I then give my position one second later as <1, 8, 3>, this is invalid as I've moved too far, the sim will place me at <1, 6, 3>. If I'd reported my position as <1, 6, 3> then it would be perfectly happy and let me move there server-side.

If my updates are arriving too slowly, then my avatar will be stopped, or automatically switched to server-side calculation if the server believes it has enough spare processing power. Or potentially a mixture of both depending on the severity, i.e the server could calculate every 6 ticks and leave the rest to the client.

At the least this would still significantly reduce the amount of physics processing by the server and simply require it to do some fairly simple logic (testing timestamps and doing vector distances) to decide what to do with an avatar. Leaving it with the responsibility of acting more like an information router to other clients, rather than having to bear the brunt of the work.

If this reduced physics processing by even half it would considerably increase the available processing power of a simulator.


Haravikk Mistral added a comment - 14/Sep/07 02:43 AM
As for the issue of hacked clients. We can already walk through walls. To prevent that (or to make it meaningless) we need better permissions systems, all of which would still be handled server-side; things like options to prevent objects being sent from disallowed parcels, or from disallowed sections of parcels (much preferred).

It would be no different than a client now that place you anywhere in the sim it likes, you just won't actually be there so won't receive chat etc.


Lex Neva added a comment - 14/Sep/07 09:49 AM
I think we just can't trust the client to handle this kind of important computation/information.

Think about how this system could be used for griefing. Even if the server tries to do some kind of smoothing out of errant positioning by the client, it might well be possible to make a client that causes your avatar to "vibrate", moving erratically all around within, say, a several-meter sphere. Why would this be useful? Well, the way griefing management currently works, if you can't right-click someone, you can't eject them from your parcel very easily. It's a serious pain in the butt even now if someone's moving around quickly while griefing your land. A "vibrating" avatar could very well be rendered nearly unclickable, making it difficult to read their nametag and impossible to right-click them, which is the quickest way to ban and eject an avatar from your land. Instead the land owner would have to go through the slow, painfully long process of opening the About Land window and banning manually, then wait for the auto-eject which can take awhile... and that's only if they can actualy see the person's quickly-moving nametag.

That's just one example that comes to mind of why this may not be such a good idea.

In order to counteract something like this, a lot of the physics calculations for the avatar done on the client would have to be reproduced and "verified" by the server anyway. This computation might well represent almost as much work as just doing the calculations on the server. Furthermore, the data produced by calculating avatar physics on the client will necessarily be less accurate than current avatar positioning data, because of the time it takes for the data to reach the sim. If you live on another continent from the sim's physical presence, traffic may take as much as 200-500 milliseconds to arrive at the sim... and then it'll have to be rebroadcast to all other clients. This will be visibly displeasing.

So what I see is a limited computational benefit, a potential for mayhem, and a rather unpleasant performance drop.


Haravikk Mistral added a comment - 17/Sep/07 03:57 AM
The issue of griefing is a failure of the current land-management tools. These are really a separate issue and need their own JIRA entry.
However, with the sim performing basic smoothing of the movement, it shouldn't be possible to do anything that we can't do already, as the server will be expecting a current position and a velocity vector from the client, meaning it knows where you think you are, and how fast you are moving and in what direction. Thus it is not possible to simple move from location to location without the simulator interpolating you when it passes your location onto other clients, or causing it to invalidate your results and ignore/smooth them.
Therefore 'vibrating' your avatar would be no different from taking the current open-source client and simply programming in a 'vibrate' loop for your controls. Moving through walls is already possible, I can't really think of any other exploits.

As for lag, same as above. Your client would be providing the simulator with a current location and a movement direction/speed relative to yourself. So if I send a position and speed, then one second later provide a valid new location and speed, then assuming the latency from me to the server has not changed, then it will agree with what I've calculated and allow me to continue calculating my own physics. When the server receives my location/speed information, it broadcasts this to all clients (including mine) so if I'm lagging horribly, then I'll keep getting put back and slow-down. Exactly as happens now if I'm lagging a lot. The client can compensate for this by sending physics results immediately, but waiting for my ping-delay before displaying the result. ie:

1. I press forward
2. Client calculates physics values and sends them
3. Client waits 500ms (my ping)
4. Client displays my avatar moving forward
5. Server response comes back about 500ms later still
6. Client ignores this as it agrees with what it expected to get back at this time.

Conceptually it's a lot more difficult to consider how latency would be affecting this system, but ultimately it is the same in the end. Currently lag may cause me to move slower than others see me and get jerked around, this one may cause me to move faster than others see me, and get jerked around. Lag isn't going to make performance any worse really.

And I've already mentioned auto-switching. If the user is lagging too badly, or the results coming from it appear invalid (validity checks are always going to be much simpler than calculating collisions) then the simulator can switch the user to server-side physics again, switching them back if their ping goes down, or their client starts giving sensible values again (ie the sim would flip back to client-side just to test every now and then to see if its improved). Clients who's performance is consistently poor when calculated client-side can simply switch to simulator-physics only.

Even if a fraction of users switch to client-side physics it alleviates a large amount of physics calculation.


Kerik Rau added a comment - 15/Dec/07 09:35 PM
For the most part the networking overhead would be worst then the physics calculation ATM. Havok 4 should drastically reduce physics load on the sims due to using better shortcuts. For the most part a lot of "non essential" items(read rotations, texture animations) are handled on the client side and don't take up much server resources.

Running a distributed model introduces many issues:

  • Not all clients will support it. I would rather we allow the chance for 3rd party viewers as they may one day become better then the current linden supplied viewer.
  • Security will be a big concern as if people are calculating physics then they may manipulate them to attack other clients. Sure the server can do sanity checks, but then that defeats most of the purpose of the distributed model.
  • Latency, if an object gets distributed to a client and they have a high ping it could mean that things would be jerky. Especially on higher load sims.
  • Overhead, having to keep track of and distribute physics calculations will probably have a greater overhead then calculating it on the same box.
  • Implementation, developing, implementing and ironing all the bugs out would likely take thousands upon thousands of man hours.

Argent Stonecutter added a comment - 11/Mar/08 08:31 PM
I'd like to see the client be smarter about physics, to reduce the effect of lag on what you see, but I'd rather not have internet latency between the avatar and the sim.