Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input: multithreaded handlers #11484

Merged
merged 2 commits into from Feb 10, 2022
Merged

Input: multithreaded handlers #11484

merged 2 commits into from Feb 10, 2022

Conversation

Megamouse
Copy link
Contributor

@Megamouse Megamouse commented Feb 3, 2022

Implements naive multithreading for input handlers.
Adds the option to choose between single-threaded and multi-threaded pad handlers.

This may improve latency if you play with 2 or more different pad handlers.
It probably won't make a difference if you only play with 2 or more pads of the same type (e.g. only DualShock3).

But I also added a config only option "Pad handler sleep (microseconds)" for the hardcore input latency fanatics.
This setting can be used in both single and multithreaded modes.
By fiddling with that value (0-100000), you may notice faster response times.
I observed a theoretical decrease in latency by 700-800 microseconds in the best case scenario.
Keep in mind that setting this value to something close to 0 will increase your cpu usage on each used core drastically and will probably drain your pad battery rather quickly.
I'd like to emphasize that I don't know if this might result in damaged pads if used over extended periods of time.

@Megamouse Megamouse added Input Optimization Optimizes existing code labels Feb 3, 2022
@Megamouse Megamouse force-pushed the more_threds branch 5 times, most recently from 2a08b41 to c5d2b2d Compare February 6, 2022 13:05
Implements naive multithreading for input handlers.
@AphelionWasTaken
Copy link

I haven't noticed any issues while testing this over the last couple of days. I've swapped between my xbox controller, ds4, and keyboard in several single and multiplayer games without issue. All pad configuration options seem to work as expected. No weird performance issues. Gamepads have not caught fire or otherwise stopped working.

@earandel
Copy link

earandel commented Feb 9, 2022

Thank you for adding this option. I have only tested on a couple of games with a DualSense controller on the macOS build but I noticed a definite decrease in gamepad input latency in multithreaded mode vs single threaded mode. Also, my DualSense disconnects (actually turns off) after about 10-15 mins of use not because of this change. This does not happen with any other apps except rpcs3 and I have not yet tracked down if there is anything I can do on my end to prevent this. When such a disconnect happens in single threaded mode, rpcs3 crashes with an exception like the following:

F {Pad Thread} SIG: Thread terminated due to fatal error: Illegal instruction at 00007ff8113097a7 (0x0f0b554889e5488d3dca970000e87d5b).
Emu Thread Name: 'Pad Thread'.

In multithreaded mode, the games notice the disconnected controller pausing allowing me to reconnect/refresh the controller and continue playing. This is a much welcome change from having to restart rpcs3 and redo anything that wasn't saved before the crash.

@Megamouse Megamouse merged commit d659703 into RPCS3:master Feb 10, 2022
@Megamouse Megamouse deleted the more_threds branch February 10, 2022 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Input Optimization Optimizes existing code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants