This is why native apps matter
I was just looking a web stream on Youtube today and was wondering why my CPU was so busy. So I fired up top and saw my web browser (Firefox) took up around 70% of a CPU to play the stream.
I thought, "this must be some high resolution crazy stream! how modern! such wow!" Then I thought, wait, this is the web, there must be something insane going on.
So I did a little experiment: I started chromium --temp-profile
on
the stream, alongside vlc
(which can also play Youtube
streams!). Then I took a snapshot of the top(1) command after 5
minutes. Here are the results:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
16332 anarcat 20 0 1805160 269684 102660 S 60,2 1,7 3:34.96 chromium
16288 anarcat 20 0 974872 119752 87532 S 33,2 0,7 1:47.51 chromium
16410 anarcat 20 0 2321152 176668 80808 S 22,0 1,1 1:15.83 vlc
6641 anarcat 20 0 21,1g 520060 137580 S 13,8 3,2 55:36.70 x-www-browser
16292 anarcat 20 0 940340 83980 67080 S 13,2 0,5 0:41.28 chromium
1656 anarcat 20 0 1970912 18736 14576 S 10,9 0,1 4:47.08 pulseaudio
2256 anarcat 20 0 435696 93468 78120 S 7,6 0,6 16:03.57 Xorg
16262 anarcat 20 0 3240272 165664 127328 S 6,2 1,0 0:31.06 chromium
920 message+ 20 0 11052 5104 2948 S 1,3 0,0 2:43.37 dbus-daemon
17915 anarcat 20 0 16664 4164 3276 R 1,3 0,0 0:02.07 top
To deconstruct this, you can see my Firefox process (masquerading as
x-www-browser
) which has been started for a long time. It's taken 55
hours of CPU time, but let's ignore that for now as it's not in the
benchmark. What I find fascinating is there are at least 4 chromium
processes running here, and they collectively take up over 7 minutes
of CPU time.
Compare this a little over one (1!!!11!!!) minute of CPU time for VLC, and you realize why people are so ranty about everything being packaged as web apps these days. It's basically using up an order of magnitudes more processing power (and therefore electric power and slave labor) to watch those silly movies in your web browsers than in a proper video player.
Keep that in mind next time you let Youtube go on a "autoplay Donald Drumpf" playlist...
Unless something changed recently, VLC is limited to 720p. That won't truly affect any conclusions, but for a completely fair comparison you'd have to take down YT to 720p, specifically in mp4 so any potential hardware acceleration can do its job on the browser too. On Chromia you might have to flip a flag to enable that at all.
Alternatively and for a better video viewing experience, you can download or pipe better quality video/audio with youtube-dl.
If I right click on a YouTube video and click "stats for nerds," I find that it typically prefers to send VP9 with Opus. The Opus stream (251) provides the best audio.
In my case, to match what YouTube sends to my browser I have to use something like this:
Play that back in VLC or mpv and you'll find it uses a lot more CPU. By contrast, force YouTube to use 720p with H.264 for hardware acceleration and it'll use less. The difference should still be pronounced, mind you, but not quite by an order of magnitude.