Why is Kubuntu using much more CPU than Windows in YouTube and other web browsing use?

9,527

Solution 1

The main reason you're seeing higher CPU consumption is the lack of hardware acceleration of video-related functions: mostly video decoding and possibly rendering. Intel's open source GPU drivers are of great quality and support these features, however browsers have some troubles implementing support.

The following information is to my best knowledge as of March 11 2020:

GPU acceleration

Both Firefox and Chrome/Chromium support GPU acceleration for rendering, but it is not enabled by default.

Firefox

You need to enable two things: Off-Main-Thread Compositing (OMTC) and WebRender.

I personally have the next settings in about:config:

layers.acceleration.force-enabled = true
gfx.webrender.all = true
gfx.webrender.compositor = true
gfx.webrender.enabled = true
dom.webgpu.enabled = true

That results in everything in about:support's Decision Log is enabled. But you might need to experiment with the settings to get a combination that works for you, because some hardware/driver combinations might experience problems.

Chrome/Chromium

GPU acceleration needs to be enabled by setting browser feature flags. chromium-flags.conf might not work depending on your browser version, but the same flags are available through chrome://flags.

My personal configuration has these flags:

--ignore-gpu-blacklist
--enable-gpu-rasterization
--enable-oop-rasterization
--enable-native-gpu-memory-buffers
--enable-zero-copy
--enable-accelerated-mjpeg-decode
--enable-accelerated-video

That results in all features in chrome://gpu being green, enabled and hardware accelerated, except for Vulkan. Once again that may vary depending on you hardware, drivers and even browser version, so experiment and find the settings that work for you.

Video decoding

No browsers implement hardware video decoding by default. Good news is that is about to change.

Firefox

Next Firefox version (75) will ship GPU video decoding feature under Wayland. You'll probably have to enable it manually.

Chromium

There is a patch for Chromium that enables GPU video decoding, but it is not merged into the main branch. That means you have to install a special version from a PPA.

Solution 2

I'd blame the video drivers ...

On windows it is known that most video codecs shove work if possible to the graphics card away from CPU, and typically manufacturers spend much more time optimizing windows-drivers than any other.

Especially open source drivers where they would have to reveal their optimizations to any competitor. And you mention specifically video playback

Solution 3

One possible issue is problems when having multiple desktops installed with all sharing the same home folder. Settings changed in one can affect another. Less so a problem with Gnome vs. Plasma, for example, but more likely in multiple desktops with the same underlying base (i.e. Unity, Gnome, Cinnamon). I've had minor issues with Unity & Gnome, for example.

You are likely to get the best user experience by installing an official flavour with your preferred desktop, if one exists. I would suggest preparing some Live USBs with the flavours you'd like to try (Lubuntu, Xubuntu... have you tried Mate, it is also lightweight and very polished), testing things in the live USB, and then installing the flavour you like best.

At the end of the day, though, I suspect that @sudodus is correct, and the Intel GPU drivers just aren't as good for Linux (a not uncommon situation). If this is the case you might not see any improvement changing desktop environment.

Share:
9,527

Related videos on Youtube

Thuat Nguyen
Author by

Thuat Nguyen

Updated on September 18, 2022

Comments

  • Thuat Nguyen
    Thuat Nguyen almost 2 years

    I am just moving to Kubuntu from Windows. And i feel that browsers on Kubuntu cost so much CPU to work.

    Example: When I watch Youtube:

    • In windows, CPU is around 12%.
    • In Kubuntu, CPU is around 50%. Same result w/18.04 & 19.10, plus Ubuntu 18.04.

    Or When I surf the Web, especially when I watch video or listen song, CPU on Kubuntu is always higher.

    I tried Firefox, Chrome, Chromium but the CPU usage is always too high.

    And here is my PC's information:

    • Intel core I5-6200U
    • VGA Intel HD Graphics 520
    • 4GB Ram

    Have anybody know how to solve this issue? Please help me. Thank you so much.

    • Admin
      Admin over 4 years
      Comments are not for extended discussion; this conversation has been moved to chat.
  • Thuat Nguyen
    Thuat Nguyen over 4 years
    Thank you so much but it does not really work on Kubuntu 19.10 but I will try your guide again on Kubuntu 18.04.
  • sudodus
    sudodus over 4 years
    +1; Please tell us which version of Ubuntu you are running, and how these tweaks work for you :-P
  • Uyghur Lives Matter
    Uyghur Lives Matter over 4 years
    Kubuntu is the offical Ubuntu flavor for KDE.
  • Vasiliy Ivashin
    Vasiliy Ivashin over 4 years
    @sudodus Just tested in Kubuntu 19.10. Got everything working in a few minutes. Firefox required switching on a few flags in about:config. chromium-flags.conf did not work, but pretty much all those settings are available through chrome://flags
  • Thuat Nguyen
    Thuat Nguyen over 4 years
    Hi @VasiliyIvashin, can you please write a guide on Chrome because I tried chromium-flags.conf and yes, it doesn't work. And I tried this tutorial: linuxuprising.com/2018/08/… but I am not sure how to use the patch, I install Chrome Dev, install h246ify, but I can't install "vdpau-va-driver DEB package".
  • Vasiliy Ivashin
    Vasiliy Ivashin over 4 years
    @ThuatNguyen you don't need VDPAU for Intel GPU, that's for Nvidia only AFAIK.
  • Vasiliy Ivashin
    Vasiliy Ivashin over 4 years
    @ThuatNguyen Basically install Chromium from PPA and VAAPI driver, go to chrome://flags and switch on ignore-gpu-blacklist, enable-gpu-rasterization, enable-oop-rasterization, enable-zero-copy, disable-accelerated-video-decode. Restart browser and check chrome://gpu. It should be mostly green. Then start a Youtube video and check chrome://media-internals - it should say kVideoDecoderName=MojoVideoDecoder
  • Thuat Nguyen
    Thuat Nguyen over 4 years
    @VasiliyIvashin This is my result when I use Chromium beta: imgur.com/a/V6LCHFb, but I haven't set API Key, Client ID yet. And I think it does not really work for me. And by the way, in Firefox, what should I change in about:config?
  • Kurankat
    Kurankat over 4 years
    Yes, and the OP seemed interested in trying a lighter desktop.
  • Thuat Nguyen
    Thuat Nguyen over 4 years
    Thank you so much, @VasiliyIvashin. It worked after I change my CPU's setting to "performance" instead of "powersave" as default. I followed this guide: community.mellanox.com/s/article/…. And in Firefox, without hardware acceleration, my CPU's usage still high even in "performance" mode. Once again, thank you so much.
  • Thuat Nguyen
    Thuat Nguyen over 4 years
    Thanks again, @VasiliyIvashin. And can you please edit your answer by adding some settings that is needed to be switched on in "chrome://flags" as you mention above and remind other people to check if their CPU's mode is performance or powersave: community.mellanox.com/s/article/…. I think it can help a lot of people because maybe they won't read these comment. Once again, thank you so so much for your helps.
  • Vasiliy Ivashin
    Vasiliy Ivashin over 4 years
    @ThuatNguyen In Firefox I have: layers.acceleration.force-enabled = true, gfx.webrender.all = true, gfx.webrender.compositor = true, gfx.webrender.enabled = true, dom.webgpu.enabled = true, so that everything in about:support's Decision Log is enabled. Videos still eat up CPU due to to SW decoding, but overall experience is smoother. Cheers!
  • Thuat Nguyen
    Thuat Nguyen over 4 years
    @VasiliyIvashin, it work perfectly. Thank you so so much for your helps. You are my life saver.
  • T. Sar
    T. Sar over 4 years
    This irony is quite funny - a regular, layman user that tries to speed up their computer by moving to Linux might end up with a slower machine because of not-so-efficient drivers.
  • Michael Hampton
    Michael Hampton over 4 years
    The browsers refused to implement hardware video decoding for years. It's good to see they have finally relented.
  • eagle275
    eagle275 over 4 years
    But the true part is that you can "recover" older weaker computers by using Linux that supports the older hardware and uses overall less resources than a modern windows
  • T. Sar
    T. Sar over 4 years
    Will this computer appear faster for what the user wants to do, tho? A poorly configured browser (somewhat of the default, when dealing with out-of-the-box mainstream browsers for Linux) can make things even worse than just running modern windows.
  • eagle275
    eagle275 over 4 years
    In this case yes - I was more referring to salvaging your (many-)years old computer to be a print- or cloud-server
  • T. Sar
    T. Sar over 4 years
    Agh. We're in 2020. We weren't supposed to still have those roadblocks on Linux. This process is a total pain for the Average Joe. (Not the fault of the answerer, just.. unfortunate that this is necessary at all)