Safari and Firefox, High CPU usage during downloads

5

1

I have found both Safari and Firefox use a very high amount of CPU during downloads (>200% CPU usage), can anyone explain as to why this happens? It occurred both before and after a complete system reinstall. It also uses the same amount of CPU despite download speed. I am using Mac OS 10.8.

enter image description here

enter image description here

I also had images of Firefox doing the same thing, but accidentally deleted them during the reinstall.

andrsnn

Posted 2013-09-19T17:19:56.860

Reputation: 457

Are you saving to HDD or SSD? Also, noticed your download speed is ~9MB/s, nice :) Does it happen when at lower speeds? – Dude named Ben – 2014-12-30T21:11:08.060

Is this a VM? I see VMWare Fusion in the list of processes...? – Dude named Ben – 2014-12-30T21:17:26.620

SSD :) Yes its very nice haha. And no, it is not a VM. Although I am running VMWare Fusion to host a VM. I eventually did a fresh reinstall which seemed to "mostly" solve the problem. Although I notice it reoccurs irregularly, but much less frequently. – andrsnn – 2015-01-02T22:58:47.740

Uhh so it's using 260% of the CPU while downloading? That seems impossible. :) – Ƭᴇcʜιᴇ007 – 2013-09-19T17:24:56.280

hence the question :) Does a higher then 100% percentage mean it is using multiple cores for that process? – andrsnn – 2013-09-19T17:25:44.773

I'm not an OSX user so I can't say for sure, but in the Windows world, no, the CPU Percentage is 100% max (1 busy core in a 2 core system would show 50% use for example), and I would expect the same from any modern OS -- but again I don't know for sure. That's why I commented on it. It seems crazy, but I have no answer. :) – Ƭᴇcʜιᴇ007 – 2013-09-19T17:28:22.040

2

I see, so it should be averaging the cores. That it is. I've had a problem along these lines with QuickLookSatellite as well. http://superuser.com/questions/617658/quicklooksatellite-mac-os-high-cpu-use

– andrsnn – 2013-09-19T17:29:45.257

Activity Monitor (or top or ps) doesn't "average the cores", so 200% means 100% for two cores. – Lri – 2013-09-19T22:55:39.850

So 400% would mean all 4 cores at 100%? Does this seem normal then? – andrsnn – 2013-09-20T17:19:21.217

Answers

1

I only came across this question today and I hope this is not too late an answer, but the short answers are yes (to your first question "I have found both Safari and Firefox use a very high amount of CPU during downloads (>200% CPU usage), can anyone explain as to why this happens?") and yes (to your comment question "Does a higher then 100% percentage mean it is using multiple cores for that process?").

The short explanation is that your Mac contains a multi-core processor - I'm guessing a minimum of 2 given that you are running OS X 10.8 - which supports hyperthreading, and this means that each physical core (a physical CPU in itself) presents multiple "logical" cores to OS X which it treats as independent logical CPUs. A process can use up to 100% of each logical core, so n logical cores means a maximum of n x 100% CPU usage per process. Hence your Activity Monitor (like Task Manager in Windows) showing CPU usage bars for each of these logical cores (as long as they are <= 4, according to Apple technical documentation on CPU usage) and you're getting readings like 157% for Firefox etc. This is not unusual and probably normal if you have multiple downloads, apps, games etc. running at the same time. But note: different app processes live in different parts of the user virtual memory space, so it is also possible to see multiple app processes which have >100% CPU usage at the same time, e.g. Firefox 157% and iTunes 200% etc.

It is impossible to see a >100% CPU usage for a process in a single-core CPU system, unless the reporting tool you are using is faulty. Firefox probably spawns a thread for each download (if you have multiple simultaneous downloads), in addition to a number of other threads for tabs, rendering etc. and other stuff going on, and your reading of 157% for the process clearly means some of these threads were being run on at least two different logical cores at the same time. A reading of 296% would indicate at least three cores being used etc. The CPU usage for a process on a multi-core processor / multi-threaded OS system is an aggregate of the CPU usages for all the threads running inside that process.

Note: on a practical level you may want to consult this if your downloading problems are specific to Firefox or are occuring repeatedly.

You can find out information on the number of physical/logical cores in your computer by using the sysctl command (in the BSD API if you are interested) - if you execute the following command in your terminal app:

$ sysctl -e hw | grep "cpu="

you should see something like this (note the comments I've inserted, not part of the output)

hw.ncpu=4         # no. of cores available to the kernel
hw.activecpu=4    # no. of logical cores actively being used by the kernel
hw.physicalcpu=2  # no. of physical cores
hw.logicalcpu=4   # no. of logical cores

ramius

Posted 2013-09-19T17:19:56.860

Reputation: 158

Hope this is not against the rules, but for a more extended discussion, inspired by this question, please see this post.

– ramius – 2015-01-18T23:50:45.247