Why is watching YouTube so cpu intensive?

My Ryzen 5600G doesn’t seem to benefit from iGPU and the cpu usage is very high, at least 60% (I assume it’s single core?).

Because AppVMs use a software-only (CPU-based) implementation of OpenGL. It seems one cannot do much about it, since it’s necessary for Qubes OS GUI isolation. Related issue.

However many people say it’s not too bad, and the performance is quite good. I feel it’s also quite significant on my i7-6500U.

To be accurate it’s not really an issue with OpenGL, although that does not change things much for the end user: the video-acceleration hardware is usually (always?) physically part of the GPU but distinct from the hw parts (what the hw world calls “IPs”) that are used for 3D acceleration. The root problem in both cases is really the lack of access to the GPU from VMs, the lack of OpenGL is just the highest-profile aspect of it, video acceleration is on the same boat :).

I can give you some specific numbers from my system (i7-3840QM) playing this video.

  • At it’s default size the CPU load is always less than 50%.
  • Going fullscreen (1080p) it’s 75% max, most of the time around 60%.

This is while having crystal clear fluid rendering without any artifacts.

1 Like

I realize this is not what you asked, I got a bit excited sharing my numbers. The other answers are correct: there is no hardware acceleration inside a qube and all rendering must be done in software.

While on the one hand the (virtual) CPU load of that particular qube (virtual machine) is significant, I do think it’s a small price to pay for the security gain.

I do not think that you can draw conclusions from the (virtual) CPU usage of a single qube to how much actual CPU time is used on your hardware. My dom0 never exceeds 15% in the above mentioned experiment. Not sure if that maps, someone with a deeper understanding of Xen should enlighten this aspect (please).

Unfortunately, YouTube does a lot of extra things in the background while your video is playing, and I guess the website developers just assumed that you are viewing their website on a device that has hardware acceleration and a multi-core CPU (which, to be fair, is 99.99% of devices in existence today…).

I have a feeling that very few of these things have much to do with the actual video… :thinking:

I have 10+ years old machines with only one or two cores in them, and the ironic thing is, when you download the video using youtube-dl and play it, it’s flawless and with almost zero resource usage. However, the fan spins up to MAX if you try and play it through Firefox… There are also severe frame drops up to ten seconds before ads load…

Hmmm… :face_with_monocle:

I’m pretty sure I could fry an egg on the CPU while visiting YouTube’s website…

(This is not in Qubes OS, because sadly, the CPUs are so old that they don’t support VT-x, so these machines run Fedora 35…and Gentoo)

4 Likes

Exactly.

Just use some Javascript blockers and you’ll notice a significant performance improvement on 70% of today’s websites incl. youtube. All that tracking of all of your mouse moves and clicks is CPU expensive.

umatrix does an excellent job for Firefox, but is unfortunately unmaintained nowadays.

4 Likes

turn off “ambient mode” in the youtube player settings. It dropped my CPU usuage by a lot and actually made it usable on Qubes.

3 Likes

You can also check out my guide about setting up mpv and ytfzf to watch YouTube without a web browser using Invidious instances, which means even better performance and also much more privacy.

1 Like

everytime i think I have the best solution for something someone comes along with a thread like this lol… Linux is wild with all multitude of solutions to a problem.

@Raist I was also having trouble with YouTube being slow. Turning off “ambient mode” was a huge improvement for me. Thank you for the suggestion!