CPU freq drop while playing games

Firstly, English is not my native language and i can have grammar mistakes
When I start playing games fps decrease from 60 to 5-15 for 3-5 minutes
~> inxi -C
CPU: Info: Quad Core model: AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx bits: 64 type: MT MCP cache: L2: 2 MiB
Speed: 423 MHz min/max: N/A Core speeds (MHz): 1: 423 2: 401 3: 622 4: 629 5: 636 6: 636 7: 635 8: 621

I’m not a gamer, but I’m guessing that the CPU is being throttled for thermal reasons if it only happens after a while. Try using lm-sensors or similar to keep track of the temperature and see if you can find anything there. Or add better cooling (if possible).

@peterhoeg, The temperature is about 80-90 degrees. For my laptop, I also use a stand with coolers during gaming as extra cooling.

It may also be important to clarify that this is only when using Vulkan. With OpenGL all works fine, but unfortunately the game does not support it recently.

It still sounds like thermal throttling to me. If I were you, I would have a script run every second that writes out the current CPU speed and temperature to a file and then try launching the game(s) in question and see if that reveals anything.

As for vulkan vs opengl, it’s entirely plausible that vulkan works the hardware harder and as a consequence the hardware runs hotter in order to trigger the throttling.

1 Like

You can use mangohud to track system stats while you play, even charting it so you can compare to the fps graph.

Without more data it’s practically impossible to tell what’s wrong. I’d also guess thermal throttling from what you’ve told us (90° is throttling territory), but it could also be that you run into more demanding scenes, that compiling shaders randomly kicks in (vulkan shaders are more expensive to compile, especially for dxvk stuff, steam does shader pre-caching to try and prevent this, but you need to allow it to do that and it takes forever), etc.

This is the first time I’ve heard of mangohud, and probably for nothing. As soon as I have time, I’ll collect these stats. I also use shader caching before the game.

Can you try using gamemoderun ? (from gamemode package if I remember correctly) it will force the CPU freq to stay at maximum when playing, increase the priority of the game and a few optimization helping to lower latency.

How do you run the games? This may affect how you install and use both mangohud and gamemode.

1 Like

I run games in Steam with the following launch parameters: gamemoderun %command%.

did you install Steam from flatpak or Nix?

From Nix with programs.steam.enable = true

csv logs

ok, so you could install mangohud in nixos packages, and use mangohud gamemoderun %command% in steam, if it doesn’t show something, try with env MANGOHUD=1 gamemoderun %command%

I’d advise to try without gamemoderun at all, from the graphs, I suspect your system is overheating because gamemoderun forces the GPU clock to maximum all the time. And after a while, your graphic card has to throttle its GPU usage (which could be interpreted by the increase of GPU load to 100% while the clock remains stable) to not heat more.

You are using Xanmod, I recommend trying with a normal kernel. Xandmod focus on latency, but not in the way you think, it barely help for video games but it can increase the load on the CPU because of constant task switching to reduce the latency. Lowering the CPU usage will reduce the heat generated in the laptop, which would allow the turbo mode of the CPU to trigger more often (it’s temperature related), and will reduce the heat to dissipate inside the laptop frame, thus allowing the GPU to heat a bit more for more performance.

I tried running without gamemode and using pkgs.linuxPackages_latest instead of xanmode. None of this worked, the results are the same.

I also cannot understand why the CPU frequency can exceed the maximum CPU frequency of 2100mhz as listed in /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq or /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

That’s the turbo mode

Actually, looking at the data, this doesn’t look like overheating to me. You’re just running into a GPU bottleneck: mangohudlog.csv · GitHub

GPU load approaches 100% (though it might be overheating, and be stuck on a low frequency because of it), meanwhile the CPU load and all the temperatures are fairly static. Actually, looking again, fps drops off a cliff once your gpu temperatures hit 80°C, almost definitely throttling even though the stated clock rate is static.

You could consider opening up the laptop and clearing any dust from the fans. You’re pretty close to maxing out your RAM too, you’re not swapping, right?

When I install nixos I set “Use swap (with hibernate)”. Swap partition size is 10.6G

That’s fine, and useful for hibernating indeed. I wouldn’t recommend disabling swap. However, if your game uses so much memory that some of it needs to be put in your swap partition, that will drastically reduce framerates (and potentially freeze your whole computer).

1 Like

I can’t access those logs (404) but the rising frame time graph smells like it’s overheating. This isn’t something you can really fix in software other than making it perform consistently bad.

Make sure you’re not blocking the air outlet. If this laptop is a few years old, consider cleaning it or getting it cleaned.