High CPU usage while using Chrome/FF or playing Youtube video in Ubuntu 18.04

10,068

I am also using Ubuntu 18.04 and I have the exact same quad core processor only I have Intel® HD Graphics 620 (Kaby Lake GT2) which is probably a fraction of the speed of your NVIDIA graphics card.

In a nutshell, "I can confirm that the System Monitor is the most accurate compared to top since it can display usage of all CPU's in real-time simultaneously, whereas the top command only displays the CPU usage as a percentage of a single CPU by default. Though if you read on I came to the conclusion its more likely that htop is the most accurate of the three"

To elaborate on that, If you run your scenario again and while playing your YouTube video you will see top shows Web Content high (When I ran your scenario my CPU was at 97%), but if you press SHIFT+i in the terminal window where your top command is running, to turn OFF Irix mode (which is ON by default), you will see the Web Content CPU usage will drop significantly.

The thing about top its been around since UNIX came about and way before multi-cpu's came about and it will only ever show the percentage of the CPU time that the process is currently using. I never use htop and I thought it looked like top with some nice enhancements judging by the description in the man page which doesn't really describe what it does well, it just says in the description "It is similar to top, but allows you to scroll vertically and horizontally." but after using it I can see it also shows each CPU usage for multi-cpu systems and when I ran your scenario I was getting the same CPU usage for each CPU in htop as per the System Monitor and could see no discrepancies between them. Correction after performing several further tests it would be more accurate to say that htop and System monitor CPU% usage is roughly the same at times, but can vary and it appears there is no manual for the Gnome-System-Monitor, though I found that htop is written in c and uses the n-curses library so it is likely that htop is more accurate because it runs within a terminal and therefore it doesn't have the additional overhead of loading and running a GUI, whereas the System Monitor does and uses GTK+ (Gimp Toolkit), so that fact should in theory give htop the edge,since we are talking about displaying realtime information these things matter, but I don't know enough about how the Gnome-System-monitor works under the hood, I only know its one of the Gnome Core Applications which could be written in (Vala, C, C++, Scheme, JavaScript, Python), but even if it was written in the most efficient language which is likely (C/C++) it still has the GTK+ overhead and evidently by comparing htop versus Gnome-System-Monitor both running in htop it is clear that htop is using significantly less resources especially in terms of CPU and Memory than the Gnome-System-Monitor is using:

enter image description here

Also take a look at the man pages for the top command specifically the following information under the CPU section:

  1. %CPU The task's share of the elapsed CPU time since the last screen update, expressed as a percentage of total CPU time. ... Also for multi-processor environments, if Irix mode is Off, top will operate in Solaris mode where a task's cpu usage will be divided by the total number of CPUs. You toggle Irix/Solaris modes with the `I' interactive command.

Finally also remember that top, htop and Gnome-System-Monitor each all consume resources and so running all three at the same time is going to impact performance, so I would recommend only using one or the other.

Also with regards to web browsers Chrome loads a new process for every new tab, where as Firefox Quantum limits the number of processes to four and so this means FFQ should in theory at least be more memory efficient.

Share:
10,068

Related videos on Youtube

Prithviraj Mitra
Author by

Prithviraj Mitra

Updated on September 18, 2022

Comments

  • Prithviraj Mitra
    Prithviraj Mitra over 1 year

    I am new in Linux(Ubuntu) and have installed Ubuntu 18.04 in my dual boot laptop recently. My system detail is as below -

    enter image description here

    Driver/GPU details --

    enter image description here

    And

    enter image description here

    When I browse sites or play youtube video in Firefox/Chrome I see the CPU usage is increasing massively through --

    1. TOP command - It gives me 70%. When I play Youtube videos sometimes it gives 150% but next moment it comes down to 30-40%.

    2. System monitor - It gives me less than 20%.

    3. HTOP -- When I play Youtube video it gives 80% sometimes.

    My question is which one is correct?

    I have tried installing Chromium and no difference in cpu usage. Also I think there is one process which is web content and that goes to high as well.I normally open 10-15 tabs in both browsers (FF and Chrome) so I can expect 20-30% usage but sometimes it becomes really ridiculous.

    I have done necessary checks/turn off like plugins/extension/hardware acceleration in Chrome and FF but nothing works.

    Any help is highly appreciated.

    • mikewhatever
      mikewhatever over 4 years
      So, you open 10-15 tabs with 10-15 youtube videos playing, and expect CPU usage to be low? Why?
    • Admin
      Admin over 4 years
      do you try to use Xorg server driver
    • Prithviraj Mitra
      Prithviraj Mitra over 4 years
      @mikewhatever No 10-15 tabs with one tab playing YT video and may be once in a month.
    • Prithviraj Mitra
      Prithviraj Mitra over 4 years
      @desertangels Yes that was by default when installed.
    • Admin
      Admin over 4 years
      do you configure Xorg module in Xorg.conf glx or dri ?
    • Prithviraj Mitra
      Prithviraj Mitra over 4 years
      @desertangels No I haven't configured for Xorg. When I installed ubuntu the Xorg option was selected.
    • Admin
      Admin over 4 years
      take a step and create one
  • Prithviraj Mitra
    Prithviraj Mitra over 4 years
    Ah now understood the top command. Thanks for the explanation. But still for one cpu and playing one 720p video with 80% cpu is ridiculous.
  • Admin
    Admin over 4 years
    Your welcome, apologies but I edited this a lot after I posted it as I wanted to be sure I answered all the points you made and that I done enough testing and research to make the answer as extensive and accurate as possible, so you may want to reread the answer. I couldn't get any one of my CPU's to 80% but if I am playing a video on youtube or watching a film on Netflix I close all other tabs to save resources, because on some browsers except FFQ every tab is a new process.
  • doug
    doug over 4 years
    "But still for one cpu and playing one 720p video with 80% cpu is ridiculous." Not sure you're paying any attention to what was said. With top go shift+i to see better representation or look in the top area of top at %Cpu(s), mainly at the us value. Here on a older Haswell (quad core with hyperthreading), a youtube 1080p vid uses about 7% total cpu, a bit less if full screen.