Emulator Issues #8240
closedMake Core::IsCPUThread() faster by using thread local storage
0%
Description
https://github.com/dolphin-emu/dolphin/pull/1987 caused a large performance regression by causing IsCPUThread() to be called in a hot path when this function was not designed to be fast.
The regression was adressed quickly in https://github.com/dolphin-emu/dolphin/pull/2067 by removing the problematic assertion in release builds, but this is not an ideal fix since it makes bugs harder to detect. Instead, IsCPUThread() should really be made faster.
I've posted an idea on how to make this faster in the comments of PR 2067: using thread-local storage to identify the CPU thread. This should make IsCPUThread() the equivalent of one memory load, aka. extremely fast compared to the current version.
Easy one for potential new contributors :)