3-8 fps in Sadrith Mora. Physics out the roof

Support for running, installing or compiling OpenMW

Before you submit a bug report for the first time, please read: Bug reporting guidelines
djdduty
Posts: 6
Joined: 08 Nov 2016, 23:47

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by djdduty »

scrawl wrote:...
A deeper issue is that as soon as the physics system can't keep up with simulating X seconds of physics in less than X seconds, we fall behind, have to incorporate those leftover frames in the next frame, causing us to fall behind even further, and the cycle repeats. (The article "fix your timestep" discusses this problem as the so-called Spiral of death, he explains it much better than I can). This is the reason why instead of moderate lag, we see FPS numbers below 1 when the physics system is overloaded. There isn't a way to fix this other than putting the game in slow motion or just making sure you don't fall behind.

The purpose of doing multiple iterations is not to fix tunneling, it is to handle stepping over more than one obstacle in the same frame (think staircases, for example), and/or getting "unstuck" via the sliding mechanism. I don't think reducing the max iterations is the right fix. I've tested reducing it to 3, and noticed there are some spots where I get stuck that worked fine with 8 iterations.

As for uncontroversial improvements, I've found one: one of the stepMove calls was not necessary in most cases. This should speed up the problematic collisions by a factor of two. Fix is pushed to master. Not sure though if that is enough for all systems.
I must have gotten confused, I assumed the solver stepping was responsible for collision accuracy for fast moving objects along with the various gameplay flags I saw in there, beyond playing with the iterations and how many physics steps there are in a frame I hadn't fully dissected the physics system yet to completely understand it, as I mentioned it my pm. I've never had the need to personally write new solvers before. My attack plan was to use the built in bullet dynamics solver to see how it performed in the same circumstances and then inspect source of it and try to replicate how that solver works for collisions. I hadn't tested things like stairs or sliding against walls as I hadn't considered the solver's responsibility there.

It's good to hear you found a more simple fix to at least solve some of the issue and I'll make sure to update my fork later and test it now, see where it can go from there.

As for fixing the physics timestep, I've run into this a few times before and... there never seems to be a "perfect" scenario, always tradeoffs. Glenn Fiedler (gafferongames author) also writes amazing networked multiplayer articles if you haven't read them before, cool guy all around.
Last edited by djdduty on 10 Dec 2016, 03:35, edited 2 times in total.
CMAugust
Posts: 285
Joined: 10 Jan 2016, 00:13

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by CMAugust »

I did some testing in Sadrith Mora with ACE's latest build in the 0.41 thread (9d8275580b). I presume this has incorporated the fix? I was not able to get the same results from the day before.

Although fps still fell to the low 30s at times simply idling in the market, it is not the single-digit slideshow it was before. Running against the slave pods from a specific angle reduced it to the teens, but that's better than 1-3 fps. This is with an i5 2500k, so clearly there is still a ways to go, but a big thanks to scrawl for the latest revision.
User avatar
werdanith
Posts: 295
Joined: 26 Aug 2011, 16:18

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by werdanith »

I'd like to thank everyone for their efforts. Sadly, while I don't doubt the commit may have helped the situation, Port Telvannis, which seems to be the worst offender for me, remains unplayable, with physics allocation escalating to over 600 in a few seconds, so I'm hoping there's room for improvement.
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by psi29a »

CMAugust wrote:Although fps still fell to the low 30s at times simply idling in the market, it is not the single-digit slideshow it was before. Running against the slave pods from a specific angle reduced it to the teens, but that's better than 1-3 fps. This is with an i5 2500k, so clearly there is still a ways to go, but a big thanks to scrawl for the latest revision.
Now that's a big fracking win right there! I have a feeling that 0.41 will make waves. :)

Yes, there is still room for improvement. It's an iterative process. :)
raven
Posts: 66
Joined: 26 May 2016, 09:54

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by raven »

I did a bit of logging just to see how bad it looks.

The worst case I've seen are 26 rays (all 8 solver iterations exhausted) per simulation step! This totally kills the performance.

The step length in those cases doesn't change much, which hints at the solver being stuck:
s0 5.77191
s1 2.44885
s2 2.44884
s3 2.44883
s4 2.44882
s5 2.44881
s6 2.44881
s7 2.4488

The steps in general are very short (< 3 units) with the actor radius being ~30 units.

EDIT:
Just spotted 57 rays...
raven
Posts: 66
Joined: 26 May 2016, 09:54

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by raven »

It looks like the solver gets stuck because the contact normal from the cast is pointing either up or down.

In this case the direction vector doesn't change, the solver keeps running against the obstacle until all iterations are exhausted.
raven
Posts: 66
Joined: 26 May 2016, 09:54

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by raven »

The worst case happens when the stepper fails due to ground slope. It will try a wider step, which means 7 casts per step attempt and 7*8+1=57 casts in total.
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by wareya »

If I'm understanding the issue correctly (I haven't read the code, just this thread), when an iteration ends up in the same state it started in, it should short circuit. This is important if each "bounce" (attempted section of motion) doesn't reliably either finish the tick's motion or reduce the motion vector to only the part parallel with the plane it hit.
raven
Posts: 66
Joined: 26 May 2016, 09:54

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by raven »

The pathologic case happens when it runs into the ground. At least I think that it is a ground contact due to the normal pointing up. When this happens the direction logic fails, sticks essentially with the same direction.

Although I've also seen a variant where it would alternate, normal vector changing between horizontal and vertical direction, without getting anywhere.

What I don't fully understand is, why stepping over fails in the ground contact case.
User avatar
Jester
Posts: 8
Joined: 30 Nov 2016, 13:06
Location: Athens
Contact:

Re: 3-8 fps in Sadrith Mora. Physics out the roof

Post by Jester »

Just noticed the release of 0.41 and came back.

After trying removing all the npcs and many objects from the city the problem remains the same.
The second i leave town it magically hits 60fps and stays there like it does in any other part of the game.
Post Reply