NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.46k stars 13.66k forks source link

TLP defaults to `powersave` scheduler, which results in terrible performance on recent kernels #119746

Open deifactor opened 3 years ago

deifactor commented 3 years ago

Describe the bug I don't fully understand the details, but according to this reddit comment, the powersave scheduler on kernels 5.8+ on a CPU without hardware p-states will always leave the CPU at its minimum clock rate. I haven't confirmed this by looking at the current CPU frequency directly , but I did confirm that switching back to 5.4 fixed the massive performance regression I noticed, as did the intel_pstate=active fix on 5.10.

IMO this should be prevented, though I'm not sure if it's through modifying the upstream TLP config on newer kernels or what.

To Reproduce Steps to reproduce the behavior:

  1. Have a CPU that doesn't support hardware pstates
  2. Enable TLP, default configuration.
  3. Use the latest kernel.

Notify maintainers

@abbradar @lovesegfault

Metadata Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:
lovesegfault commented 3 years ago

I definitely think this should be addressed by TLP changing their defaults and not by us.

andersk commented 3 years ago

We already override the default if config.powerManagement.cpuFreqGovernor is set (#94064):

https://github.com/NixOS/nixpkgs/blob/4216cf5aee04260b8433cc8bd6eecaee8ed1e687/nixos/modules/services/hardware/tlp.nix#L74-L84

which it is if you ran nixos-generate-config.pl in 17.03 or later (#21423):

https://github.com/NixOS/nixpkgs/blob/44fa00a5b8e2895247b61a635f96ba95e6dd91c5/nixos/modules/installer/tools/nixos-generate-config.pl#L95-L107

deifactor commented 3 years ago

Hmm. I wonder if it's reasonable to somehow detect if the CPU is too old and warn the user "hey, this is going to cause very bad performance issues, this is probably not what you want". I don't know how actual Nix maintainers feel, but IMO enabling the default should Just Work, even if that means not doing what upstream does.

@andersk Yeah, I had to make that change in my hardware config too. I don't remember what it was set to on machine init, but I remember I changed it to powersave at some point.

justinlovinger commented 3 years ago

I didn't look around much to verify this, but according to the Arch wiki, CPUs using acpi-cpufreq driver should default to schedutil since 5.10. I don't think this is just an upstream issue, and it is going to cause a lot of pain when NixOS 21.05 releases.

deifactor commented 3 years ago

I saw this got added to 21.05, but that's already out. Any update on this?

lovesegfault commented 2 years ago

No one is actively working on this. PRs are welcome. I will review and merge a fix if someone has the time to write one.

Artturin commented 1 year ago

Is there anything actionable here?