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

[Feature Request] Steam Deck - Toggle to enable/disable Simultaneous Multithreading (SMT) in Quick Menu or game properties #864

Open
Shaunathanz opened this issue Sep 29, 2022 · 45 comments

Comments

@Shaunathanz
Copy link

Shaunathanz commented Sep 29, 2022

Your system information

  • Steam client version: n/a
  • SteamOS version: n/a
  • Opted into Steam client beta?: n/a
  • Opted into SteamOS beta?: n/a
  • Have you checked for updates in Settings > System?: n/a

Please describe your issue in as much detail as possible:

It would be beneficial for CPU constrained games or programs that don't make use of more than 4 threads or don't benefit from the use of more threads to be able to disable SMT. Right now this can be accomplished with Decky Loader and the PowerTools plugin but official support would likely be beneficial to tinkerers and performance junkies (and people that like to run Dolphin & PCSX2 at full speed)

Steps for reproducing this issue:

  1. Run a CPU intensive game in game mode
  2. Take note of FPS
  3. Disable SMT
  4. Run game again
  5. Notice the difference
@Shaunathanz Shaunathanz changed the title [Feature Request] Toggle to enable/disable Simultaneous Multithreading (SMT) in Quick Menu or game properties [Feature Request] Steam Deck - Toggle to enable/disable Simultaneous Multithreading (SMT) in Quick Menu or game properties Sep 29, 2022
@evelikov
Copy link

What's the advantage of disabling SMT over settings a power-cap via the existing UI? Reduce the GPU clocks, reduce the power envelope - the CPU clock to lower frequencies. Thus the FPS and temperatures stay within my range of interest.

This is what I've been using for a bunch of older games with lower hardware requirements. It works like a charm.

AFAICT it's possible to disable SMT at runtime via /sys/devices/system/cpu/smt/control although writing to it requires root access which is a big red flag, usually.

@james2432
Copy link

james2432 commented Sep 30, 2022

emulation runs better when cores aren't flooded with threads and have dedicated cores. TDP doesn't do that

I've tested this with power tools decky plugin

@evelikov
Copy link

evelikov commented Oct 1, 2022

Am I understanding this correctly, that emulators want to avoid bouncing threads across cores?

If it were me I would use pthread_setaffinity_np() or the Windows variant to achieve that. IMHO it scales much better than asking your users to disable cores or SMT.

@Shaunathanz
Copy link
Author

Am I understanding this correctly, that emulators want to avoid bouncing threads across cores?

If it were me I would use pthread_setaffinity_np() or the Windows variant to achieve that. IMHO it scales much better than asking your users to disable cores or SMT.

Not every game is a AAA blockbuster that is programmed in a way where it makes effective use of multiple threads per physical core, especially not games developed prior to the PS4/XBONE generation of consoles. Many games run better with a single thread running on a single core and no sharing processing power between threads.

Users being able to toggle SMT is hardly a risk to system stability or the end user experience.

@evelikov
Copy link

evelikov commented Oct 4, 2022

Suspect that most emulators have DB of quirks already. Extending those to cover the optimal topology sounds reasonable IMHO.

I'm not arguing against a SMT toggle, but high-lighting that pushing this decision to others scales very poorly.

@NightHammer1000
Copy link

This has not only uses with Emulators, but with other Games as well. Especially older onces who dont scale well with Multicore Processors. Encountered a few of them already. Adapting this would be a good Idea.
Or at least a Enviroment Variable to be passed at launch would be great for tinkering.

@Daasin
Copy link

Daasin commented Oct 15, 2022

emulation runs better when cores aren't flooded with threads and have dedicated cores. TDP doesn't do that

I've tested this with power tools decky plugin
@evelikov

Not even just emulation but could have advantages for single-threaded stuff that are more optimised to expect that situation. Didn't people used to do that kinda thing for getting the most out of 1st Gen Ryzen? 🤔 (With either OC + Undervolt or just with the automatic settings)

@esotericode
Copy link

Noticing poor performance in emulators such as PCSX2 led me to this post. Disabling SMT with Powertools works like a charm and all my performance issue are resolved. I just wanted to also say that I enthusiastically support a feature like this in the official OS.

@NightHammer1000
Copy link

Affected Emulators I noticed so far:

Dolphin
PCSX2
RPCS3
YUZU
Ryujinx

All these Emulators give way more Performance with SMT off.

@Daniel-Griffiths
Copy link

Having official support for this would be great, even if it was only added in the steam decks developer settings.

@ds22x
Copy link

ds22x commented Nov 4, 2022

A SMT toggle almost feels essential for emulators and single threaded games that require a higher and stable clockspeed.

In general though, the options included in Powertools being officially part of Steam OS as an advanced menu would be a godsend.

@Daasin
Copy link

Daasin commented Nov 6, 2022

Having official support for this would be great, even if it was only added in the steam decks developer settings.

Or in the UEFI menu if just having the setting out there is seen as a bad move

@xperia64
Copy link

xperia64 commented Nov 8, 2022

Having official support for this would be great, even if it was only added in the steam decks developer settings.

Or in the UEFI menu if just having the setting out there is seen as a bad move

imo the Developer Settings/the UEFI menu is a no-go. It needs to be done per-game like TDP or Manual GPU Frequency override, and I'm certainly not going to reboot every time I switch between what I'm playing especially when it can be done at the OS level effectively as seen in PowerTools.

And again, it's not just emulators. Many older games run better with higher frequencies on fewer threads. The same TDP cap on 8 threads compared to 4 results in lower frequencies. Proton already acknowledges this with its WINE_CPU_TOPOLOGY override (in proton-cpu-topology-overrides.patch), but this obviously doesn't work for native Linux applications.

@aujang
Copy link

aujang commented Dec 12, 2022

I wanted to note my own support for this; having control over core count exposed in SteamOS Advanced Settings/Developer Mode would be highly preferable to the current Decky/PowerTools method. Even better would be having it configurable on a per-game-launch basis, as opposed to a universal toggle, but honestly any functionality would be a massive help (and improvement over the existing solutions).

@othyn
Copy link

othyn commented Jan 5, 2023

Highly support adding something like this under the existing per-game options under the advanced performance overlay, as how all other performance tweaks are currently applied. Basically mirroring the existing Power Tools implementation would be really helpful to have as a native feature. It comes up across a lot of games and emulators where disabling SMT yeilds significant results.

@bugworm
Copy link

bugworm commented Jan 6, 2023

For those who waits this feature: you can kinda do that already without any third-party software. SteamOS has taskset utility, which is used to set CPU affinity of a process and doesn't need root in order to work. To use it as "SMT off button", change launch parameters to taskset -c 0,2,4,6 %command%. It will force the game to use only cores, while threads will do background tasks. From my limited testing this is actually a better option than disabling threads altogether.

@ds22x
Copy link

ds22x commented Jan 8, 2023

Tried the taskset suggestion as shown above, but while it does seem to make it a bit more stable due to forcing a game to stay on the assigned cores, it doesn't provide the performance boost seen when disabling SMT.

@Shaunathanz
Copy link
Author

Shaunathanz commented Feb 17, 2023

It's happening guys, thanks to all those who chimed in to help make SteamOS better for everyone.

https://twitter.com/Plagman2/status/1626041563737645056

@james2432
Copy link

this could probably not be required as of the 3.5 release of steamOS with the new kernel:

https://www.pcgamer.com/steamos-35-is-almost-here-includes-a-fix-for-the-steam-decks-sneakiest-performance-bug/

@othyn
Copy link

othyn commented Mar 16, 2023

Interesting, so TLDR for those not wanting to read the article, Valve didn't want to add the toggle into SteamOS natively as they saw the need to disable SMT at all as a bug, SteamOS 3.5 intends to fix that.

The summary is that AMD discovered a Linux kernel bug that invalidates a cores cache once a thread sleeps, meaning the other thread using the core (as that's what SMT is) would loose access to anything in the cache and have to go refetch it from memory, which is comparitively slow, causing performance issues in older (or emulated) games.

Newer software and games can apply patches to work around that, where as older games and (even in emulators) will not. Instead of Valve taking the approach of placing this on the user, and applauds the efforts of things like PowerTools for providing the SMT toggle as a work around, their goal was always to try and patch the bug so that SMT never has to be disabled in the first place and correct performance is always attained.

With SteamOS 3.5 containing this patch, they're hoping the need to disable SMT at all will go away, but are listening to user feedback post-update to see how that works in reality.

@bangstk
Copy link

bangstk commented Mar 17, 2023

Steam OS 3.5 with Kernel 6.1.12-valve2-1-neptune-61 is out on steam deck preview branch, but unfortunately I am not seeing the benefit of the SMT fix that is supposed to be in the new kernel.

Test case:
Dolphin, playing Metroid Prime 2, open the scan visor in the first room.
With SMT on, the game slows to 35FPS or so. With SMT off, it stays around 60FPS. This is still the case in the new Kernel 6.1 in steam deck preview.

Perhaps the SMT changes aren't in the kernel yet?

@waspennator
Copy link

waspennator commented Mar 28, 2023

Shouldn't the changes already be in the kernel if they are rebasing to 6.1? Unless there's something else bottlenecking it or we have to wait until steamos 3.5 shows up on the beta branch to see it merged in properly?

Unless it's actually in the main update branch on deck, I'm unsure

@justinweiss
Copy link

justinweiss commented Apr 21, 2023

@bangstk I saw the same thing on both the main channel and a Ubuntu live USB running the 6.2 kernel -- SMT off still made a huge difference to Yuzu performance.

There's definitely still something weird going on apart from SMT. With SMT on, all 8 cores run at 2000 MHz and only show around 40% utilization, but I wasn't getting full speed. But then locking the GPU anywhere 1200MHz or higher, all 8 cores would boost up until Yuzu ran at full speed, which is the opposite of what I'd expect. Combined with #957, and being able to resolve that one by toggling the GPU frequency lock (no matter what it's set to!) it seems like the power management can get flaky.

EDIT: I'm pretty sure it's this bug. The symptoms are really similar and the workarounds have an effect: https://gitlab.freedesktop.org/drm/amd/-/issues/1500 (the workarounds don't entirely fix the problem, though)

@waspennator
Copy link

Honestly kinda curious if Sonic Generations runs better on the main branch or not out of the box now. Cause either the fixes aren't there yet, or they are in and certain programs like emulators are being bottlenecked by smt in some other way.

Or maybe it'll be easier to test out when steamos 3.5 lands in Preview or beta, cause I've seen someone on the deck reddit say smt performance is better and some still saying it's bad.

@esotericode
Copy link

I switched to the preview branch but there's no new kernel for me like @bangstk mentioned. I wonder if anyone else has access to it or did Valve pull the update or something like that?

@justinweiss
Copy link

It's on the main channel, which only appears if you turn on "Show Advanced Update Channels" in the developer settings. I wouldn't recommend it right now, especially if you use an SD card or made any BIOS tweaks, since it changes the SD card path and updates the BIOS.

@bangstk
Copy link

bangstk commented May 2, 2023

PowerTools is likely messing with the CPU clock somehow when SMT is toggled off. This hurts battery life, but does push emulators and old games up to a more acceptable level of performance. I really think the whole idea of turning SMT off was a red herring.

Nope. I did not even have powertools installed for the test. I did nothing but write 'off' to /sys/devices/system/cpu/smt/control
Any changes to cpu clock is solely as a consequence of SMT being turned off, not something powertools is doing.

@waspennator
Copy link

waspennator commented May 2, 2023

So is this something that can be fixed or will steam deck need an option to turn off smt?

Cause I'm guessing the specific smt fixes should be in main by now.

@esotericode
Copy link

@waspennator

I'm also really curious to know if the changes in the main branch actually resolve the performance issues with emulators or not. I've seen conflicting reports between "totally fixed" and "not at all" so I dunno what to believe.

@Shaunathanz
Copy link
Author

Shaunathanz commented Jun 25, 2023

I am still seeing significantly better performance in stress testing scenarios with SMT disabled on the latest stable branch. I was able to boost the FPS in Metroid Prime 2 Echoes by 10%

@NGnius
Copy link

NGnius commented Jun 25, 2023

SMT fixes are still only in Main dev branch, not Stable or Beta (yet).

@waspennator
Copy link

waspennator commented Sep 19, 2023

Seems like 3.5 with the smt fixes finally hit preview.

@waspennator
Copy link

Checking around, seems like it's helping for some games (Smt Digital Devil Saga, Gamecube games like Timesplitters, Ssx 3, burnout 2,) but some are saying smt off still gives better peformance for others (Valkyrie Profile, Gran Turismo 4). Haven't tried 3.5 yet myself. (waiting for issues to get ironed out)

Honestly curious if there's something else going on, like if smt is effecting boost clock speeds or if a newer linux kernel might have more fixes.

@bangstk
Copy link

bangstk commented Oct 30, 2023

The Metroid Prime 2 Scan Visor performs better, it is about 40FPS now rather than 30.
However, it still performs at about 60FPS with SMT disabled.

@james2432
Copy link

having tested 3.5.0 it does seem better in terms of performance. Tested with yuzu and cemu as well as a handful of games in my steam library before and after upgrading.

@ds22x
Copy link

ds22x commented Oct 30, 2023

The Metroid Prime 2 Scan Visor performs better, it is about 40FPS now rather than 30. However, it still performs at about 60FPS with SMT disabled.

Could be because disabling SMT forces one of the remaining cores to run at a constant 3.5GHz.

@Shaunathanz
Copy link
Author

In my limited testing during work today with SteamOS 3.5.5 I am seeing no benefit to disabling SMT anymore. Not only is performance better in emulation (GC & Switch tested) but it is better on certain PC games, and I actually see worse performance with SMT off even if only marginally.

@Shaunathanz
Copy link
Author

After some additional time playing around I'm seeing some situations still where SMT helps, it's a mixed bag I guess. N64 with RetroArch performance better with SMT off.

@esotericode
Copy link

I still experience benefits from disabled SMT in the PCSX2 emulator. If it's not possible to fix this issue, perhaps it would be possible to give users the ability to disable SMT officially as a toggle? Even better would be ability to lock CPU and GPU clock speed where you want it like with PowerTools.

@waspennator
Copy link

waspennator commented Nov 20, 2023

Considering they said that they consider needing to turn off smt is a bug in general, dunno if they'll consider adding a toggle to turn it off, unless that gitlab report means it won't ever be fixed for a long while.

Dunno if we should try to ask someone like @kisak-valve or Pierre or Lawrence and tell them that either the smt fixes need more work or that they should just merge power tools for Steamos 3.6, I know 3.5 also introduced a major performance bug where the gpu clock constantly drops down

@esotericode
Copy link

Are there any other, perhaps better ways to adjust CPU / GPU clocks and more specifically lock them to a specific value? I have been using Decky Loader with the Power Tools plugin which is pretty much the popular way to do it, but it is often super glichy and doesn't apply the values I set. Sometimes I have to keep toggling it on and off, sometimes rebooting the whole Steam Deck to get it to work. Honestly, would it be possible to permanently just lock the performance to one state?

I almost entirely use my Steam Deck for emulation, and certain emulators like those for Gamecube, PS2, and others GREATLY benefit from setting custom locked frequencies.

@evelikov
Copy link

Fwiw the Steam client had support for settings the GPU clock manually for years. Personally I use that in conjunction with TDP, which effectively controls the CPU clock as well.

@waspennator
Copy link

Bumping again, I still see some people reporting smt issues here and on the steam community hub like #1274, is there something more that could be done about it or is this going to need an smt toggle built in?

@waspennator
Copy link

Any update on this? I still see people debate back and forth about games that need SMT off to work better.

@NikoBellicRU
Copy link

I also have slowdowns in pcsx2 if i don't turn off smt, we can use power tools to fix it but i would like to have a official fix cause in my case i only use decky loader cause of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests