openvr icon indicating copy to clipboard operation
openvr copied to clipboard

UpdateActionState is slow, significant % of frame time is spent in that OpenVR function

Open sbsce opened this issue 6 years ago • 4 comments

I see the UpdateActionState call take a significant % of my games performance. On average, that function alone takes 0.3 ms. Is it supposed to take so long?

I am profiling on an i7 5820k, with newest SteamVR beta.

Is it normal that it takes 0.3 ms, and that can't be improved in any way? 0.3 ms is a lot for something like this when you only have a frame budget of 6.9 ms on 144 hz. In issue #925, it was said that the function is "mostly a bunch of lockless shared memory reads", and I think that surely shouldn't take 0.3 ms?

sbsce avatar Sep 18 '19 20:09 sbsce

I see this same function take up about 7-8% of my game thread. As mentioned by OP, with Index at 144hz it is a significant fraction of the available time.

muchcharles avatar Sep 18 '19 20:09 muchcharles

I'd like to bump this because I still see the exact same issue. UpdateActionState takes roughly 10% of my CPU frametime with the most recent SteamVR version, measured with the Visual Studio Profiler, which seems way too much for that function.

image

I am sure UpdateActionState could be optimized a lot resulting in a ~10% CPU performance boost for a lot of SteamVR games.

sbsce avatar Jan 30 '22 01:01 sbsce

First, we don't know how IVRIput::UpdateActionState() is implemented under the hood, the only thing we know from the description is that it updates all actions, no matter how many there are, all of them get updated. Because we don't know how it works under the hood we can't say it can be optimized at all, it could be using some inefficient container but it might as well be using a very efficient one instead, we can't say for sure.

Personally I decouple input handling from my render thread, I hate to have performance like VRChat, specially knowing what usually happens in drivers on input updates... Trust me 10% is not that bad even, it can be way worse...

okawo80085 avatar Mar 09 '22 13:03 okawo80085

We are encountering an issue with this where if the user takes off their headset for a short period of time and after putting the headset back on the CVRInput.UpdateActionState calls a native function in openvr and its using 50% of the CPU time.

image

Wully616 avatar Jul 25 '23 17:07 Wully616