[H-GEN] Hyperthreading and CPU utilisation

Anthony Towns aj at azure.humbug.org.au
Mon Aug 25 05:21:21 EDT 2003


On Mon, Aug 25, 2003 at 05:20:19PM +1000, Michael Anthon wrote:
> I guess the problem I'm trying to get my head around is that from my
> (admittedly limited) understanding of HT, 2 processes running on the one
> HT CPU will not run as fast as 2 processes running on 2 separate CPUs

In some cases they will (or so close as to make no difference). I'm not
sure what the common case is.

As far as Linux userspace is concerned (afaik), you can't really tell;
if the two CPUs aren't both able to run at full speed you'll just see
things going a bit slower than you would if you had a real 4-way box.

> I am using cacti to monitor CPU usage on my servers, using snmp to read
> the jiffy counters from /proc/stat.  My first surprise was that on this
> system these counters return 4 times the expected values although with
> hind sight it makes more sense.  The most confusing thing though is that
> a single process running flat out as with the cat mentioned earlier then
> it ends up being by both the jiffy counter and top method (since both
> derive from the /proc/stat values) running at 25% of full load.  I just
> get the feeling that it's not really 25%, probably really closer to 50%.

More like, say 30%. I'm not quite sure I have this exactly right, but
basically if you have one process doing non-stop floating point ops,
and another doing non-stop integer math, then they can both run at full
speed at the same time, on a single hyperthreading CPU.

Similarly, if one virtual CPU spends a lot of its time waiting on memory
accesses, the other virtual CPU can do useful work.

I have a feeling that if you have two processes doing integer ops,
then there might be something special done to let both these operate at
almost full speed too, but I'm not sure. I'm not exactly sure what the
pessimal case is (ie, when exactly a hyperthreaded CPU isn't any better
than a single non-hyperthreaded CPU).

So basically, if you're only running one process, you're only using
about half of a single hyperthreaded CPU, which is about 25%/30% of your
system's total power.

OTOH, it's much too intricate to really represent *well* without analysing
the actual programs you're running, so Linux basically treats them as
first class CPUs, except for some scheduling optimisations.

> This is the issue I can't reconcile since there doesn't seem to be a way
> to measure it.

You can measure performance you're getting, but you can't really measure
the unused capacity remaining; this is because how much you have available
depends on what exactly you want to do with it.

I'm not *really* up on the details of this, but the above is approximately
accurate.

Cheers,
aj

-- 
Anthony Towns <aj at humbug.org.au> <http://azure.humbug.org.au/~aj/>
I don't speak for anyone save myself. GPG signed mail preferred.

       ``Is this some kind of psych test?
                      Am I getting paid for this?''
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 307 bytes
Desc: not available
URL: <http://lists.humbug.org.au/pipermail/general/attachments/20030825/b050cc49/attachment.sig>


More information about the General mailing list