Author Topic: Strange SDL/CPU behaviour  (Read 4890 times)

Pieter Hulshoff

  • Administrator
  • Hero Member
  • *****
  • Posts: 1543
  • Karma: +46/-14
    • View Profile
    • Towel 42
Strange SDL/CPU behaviour
« on: January 21, 2017, 07:41:48 AM »
I figured I'd post the question here; perhaps any of you have an answer. I've noticed some strange behaviour with SDL vs my CPU. This behaviour is manifested in RetroFE as well as when I run MAME with a simple game like Pacman without throttling (so maximum speed). For some strange reason, the intel powersave kicks in, and the CPU is scaled down to 800 MHz. This doesn't happen when I run Pacman at 100% speed or when I run a demanding game like Radiant Silvergun. I've tried everything I could find online, but no luck so far. Considering the behaviour with Radiant Silvergun, I doubt it's a heat problem. The CPU has no trouble running at 2400-2500 MHz for long times during that game.

I think this downscaling is causing video decoding problems for me as well; my CPU can't keep up on rare occasions. When I reduce the FPS for RetroFE from a maximum of 60 to 30 or even 24, this problem disappears, and my CPU is happily running at 2000-2500 MHz. Any thoughts?

PinealServo

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Strange SDL/CPU behaviour
« Reply #1 on: January 21, 2017, 09:57:18 AM »
Apparently the actual frequency is set by the CPU itself in accordance with a "policy" setting given by the OS. How the OS determines what policy to set probably varies, but there's some documentation here: https://www.kernel.org/doc/Documentation/cpu-freq/intel-pstate.txt regarding how the Linux kernel does it. There are even instructions in there to get a trace of pstate and cpu_frequency events that might help you track it down, assuming you're using Linux. You should be able to put it in 'performance' mode and have it stay scaled up more often as well.

I guess there's just some odd interaction between the algorithm used to decide when to do the frequency scaling and your particular workloads, although I can't imagine what it would be to make it scale back in the situations you described.

Pieter Hulshoff

  • Administrator
  • Hero Member
  • *****
  • Posts: 1543
  • Karma: +46/-14
    • View Profile
    • Towel 42
Re: Strange SDL/CPU behaviour
« Reply #2 on: January 21, 2017, 11:01:10 AM »
I'm familiar with the scaling principle, and even tried everything from turning off speedstep, c states, setting performance mode, and setting the minimum frequency to 2 GHz. The CPU ignores it all. 😢

Sent from my SM-G920F using Tapatalk


Pieter Hulshoff

  • Administrator
  • Hero Member
  • *****
  • Posts: 1543
  • Karma: +46/-14
    • View Profile
    • Towel 42
Re: Strange SDL/CPU behaviour
« Reply #3 on: January 21, 2017, 01:06:32 PM »
Just look at what cpufreq-info tells me:
-----
cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 0.97 ms.
  hardware limits: 800 MHz - 2.60 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 2.00 GHz and 2.60 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz (asserted by call to hardware).
analyzing CPU 1:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 1
  CPUs which need to have their frequency coordinated by software: 1
  maximum transition latency: 0.97 ms.
  hardware limits: 800 MHz - 2.60 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 2.00 GHz and 2.60 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz (asserted by call to hardware).
analyzing CPU 2:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 2
  CPUs which need to have their frequency coordinated by software: 2
  maximum transition latency: 0.97 ms.
  hardware limits: 800 MHz - 2.60 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 2.00 GHz and 2.60 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz (asserted by call to hardware).
analyzing CPU 3:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 3
  CPUs which need to have their frequency coordinated by software: 3
  maximum transition latency: 0.97 ms.
  hardware limits: 800 MHz - 2.60 GHz
  available cpufreq governors: performance, powersave
  current policy: frequency should be within 2.00 GHz and 2.60 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency is 800 MHz (asserted by call to hardware).
-----

Sent from my SM-G920F using Tapatalk


PinealServo

  • Newbie
  • *
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: Strange SDL/CPU behaviour
« Reply #4 on: January 21, 2017, 08:33:56 PM »
I dunno, it could be anything from a kernel bug, a SMBIOS bug that's overriding what the kernel sets, or even a weird physical artifact in the CPU that makes it think it's hotter than it is with certain workloads. I had some brief experience with system-level firmware inner workings on Intel boards many years ago, and it's pretty deep magic with secret NDA-only manuals for some parts of it, so I'm not surprised that weird stuff happens in these areas especially in Linux where developers often can't get the secret manuals or access to the BIOS firmware code.

Hopefully it's a relatively simple thing that you can work around, though. Let us know if you figure it out!

Pieter Hulshoff

  • Administrator
  • Hero Member
  • *****
  • Posts: 1543
  • Karma: +46/-14
    • View Profile
    • Towel 42
Re: Strange SDL/CPU behaviour
« Reply #5 on: January 21, 2017, 08:35:59 PM »
I can change RetroFE to 24 or 30 FPS, but I doubt anyone else will be happy with that. 😀

Sent from my SM-G920F using Tapatalk


KMetalMind

  • Newbie
  • *
  • Posts: 44
  • Karma: +1/-0
    • View Profile
Re: Strange SDL/CPU behaviour
« Reply #6 on: February 04, 2017, 08:26:11 AM »
Maybe you could add a main setting for FPS?  ??? I donĀ“t know how hard that would be, but if it fixes some of your problems, it may help others as well...