ryujinx/src
riperiperi c1ed150949
Kernel: Wake cores from idle directly rather than through a host thread (#6837)
* Kernel: Wake cores from idle directly rather than through a host thread

Right now when a core enters an idle state, leaving that idle state requires us to first signal the core's idle thread, which then signals the correct thread that we want to run on the core. This means that in a lot of cases, we're paying double for a thread to be woken from an idle state.

This PR moves this process to happen on the thread that is waking others out of idle, instead of an idle thread that needs to be woken first.

For compatibility the process has been kept as similar as possible - the process for IdleThreadLoop has been migrated to TryLeaveIdle, and is gated by a condition variable that lets it run only once at a time for each core. A core is only considered for wake from idle if idle is both active and has been signalled - the signal is consumed and the active state is cleared when the core leaves idle.

Dummy threads (just the idle thread at the moment) have been changed to have no host thread, as the work is now done by threads entering idle and signalling out of it.

This could put a bit of extra work on threads that would have triggered `_idleInterruptEvent` before, but I'd expect less work than signalling all those reset events and the OS overhead that follows. Worst case is that other threads performing these signals at the same time will have to wait for each other, but it's still going to be a very short amount of time.

Improvements are best seen in games with heavy (or very misguided) multithreading, such as Pokemon: Legends Arceus. Improvements are expected in Scarlet/Violet and TOTK, but are harder to measure.

Testing on Linux/MacOS still to be done, definitely need to test more games as this affects all of them (obviously) and any issues might be rare to encounter.

* Remove _idleThread entirely

* Use spinwait so we don't completely blast the CPU with cmpxchg

* Didn't I already do this

* Cleanup
2024-05-22 17:47:27 -03:00
..
ARMeilleure Replace "List.ForEach" for "foreach" (#6783) 2024-05-08 13:53:25 +02:00
Ryujinx Disable keyboard controller input while swkbd is open (foreground) (second attempt) (#6808) 2024-05-17 16:58:03 -03:00
Ryujinx.Audio Update audio renderer to REV12: Add support for splitter biquad filter (#6813) 2024-05-17 16:46:43 -03:00
Ryujinx.Audio.Backends.OpenAL Migrate Audio service to new IPC (#6285) 2024-02-22 16:58:33 -03:00
Ryujinx.Audio.Backends.SDL2 Use pooled memory and avoid memory copies (#6691) 2024-04-21 12:57:35 +02:00
Ryujinx.Audio.Backends.SoundIo Use pooled memory and avoid memory copies (#6691) 2024-04-21 12:57:35 +02:00
Ryujinx.Common chore: remove repetitive words (#6690) 2024-04-19 09:45:51 -03:00
Ryujinx.Cpu implement MemoryManagerHostTracked.GetReadOnlySequence() (#6695) 2024-04-21 16:34:04 -03:00
Ryujinx.Graphics.Device Texture loading: reduce memory allocations (#6623) 2024-04-14 17:06:14 -03:00
Ryujinx.Graphics.GAL GPU: Migrate buffers on GPU project, pre-emptively flush device local mappings (#6794) 2024-05-19 16:53:37 -03:00
Ryujinx.Graphics.Gpu GPU: Migrate buffers on GPU project, pre-emptively flush device local mappings (#6794) 2024-05-19 16:53:37 -03:00
Ryujinx.Graphics.Host1x Add a separate device memory manager (#6153) 2024-01-22 17:14:46 -03:00
Ryujinx.Graphics.Nvdec Add a separate device memory manager (#6153) 2024-01-22 17:14:46 -03:00
Ryujinx.Graphics.Nvdec.FFmpeg editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
Ryujinx.Graphics.Nvdec.Vp9 editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
Ryujinx.Graphics.OpenGL GPU: Migrate buffers on GPU project, pre-emptively flush device local mappings (#6794) 2024-05-19 16:53:37 -03:00
Ryujinx.Graphics.Shader Add support for bindless textures from storage buffer on Vulkan (#6721) 2024-05-14 16:47:16 +02:00
Ryujinx.Graphics.Texture Texture loading: reduce memory allocations (#6623) 2024-04-14 17:06:14 -03:00
Ryujinx.Graphics.Vic Remove Vic Reference to Host1x (#6277) 2024-02-08 20:01:03 +01:00
Ryujinx.Graphics.Video editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
Ryujinx.Graphics.Vulkan GPU: Migrate buffers on GPU project, pre-emptively flush device local mappings (#6794) 2024-05-19 16:53:37 -03:00
Ryujinx.Gtk3 Disable keyboard controller input while swkbd is open (foreground) (second attempt) (#6808) 2024-05-17 16:58:03 -03:00
Ryujinx.Headless.SDL2 Add linux specific files to local builds (#6762) 2024-05-14 16:06:40 +02:00
Ryujinx.HLE Kernel: Wake cores from idle directly rather than through a host thread (#6837) 2024-05-22 17:47:27 -03:00
Ryujinx.Horizon Updating Concentus dependency to speed up Opus decoding (#6757) 2024-05-20 18:38:38 -03:00
Ryujinx.Horizon.Common Migrate Audio service to new IPC (#6285) 2024-02-22 16:58:33 -03:00
Ryujinx.Horizon.Generators Audio rendering: reduce memory allocations (#6604) 2024-04-07 18:07:32 -03:00
Ryujinx.Horizon.Kernel.Generators editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
Ryujinx.Input Fix another NullReferenceException (#6826) 2024-05-17 20:11:30 -03:00
Ryujinx.Input.SDL2 Input: Improve controller identification (#6029) 2024-01-22 17:02:44 -03:00
Ryujinx.Memory implement MemoryManagerHostTracked.GetReadOnlySequence() (#6695) 2024-04-21 16:34:04 -03:00
Ryujinx.SDL2.Common Load custom SDL mappings from application data folder (#6295) 2024-02-10 19:41:02 +01:00
Ryujinx.ShaderTools Add support for bindless textures from shader input (vertex buffer) on Vulkan (#6577) 2024-04-22 15:05:55 -03:00
Ryujinx.Tests Update audio renderer to REV12: Add support for splitter biquad filter (#6813) 2024-05-17 16:46:43 -03:00
Ryujinx.Tests.Memory Delete old 16KB page workarounds (#6584) 2024-04-06 13:51:44 -03:00
Ryujinx.Tests.Unicorn editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00
Ryujinx.UI.Common Improves some log messages and fixes a typo (#6773) 2024-05-15 18:10:47 +02:00
Ryujinx.UI.LocaleGenerator Infra: Capitalisation Consistency (#6296) 2024-02-11 03:09:18 +01:00
Spv.Generator editorconfig: Set default encoding to UTF-8 (#5793) 2023-12-04 14:17:13 +01:00