[Nottingham] CPU idle cycles

Roger Light roger at atchoo.org
Mon Jun 18 19:56:53 BST 2007


On 18/06/07, Martin <martin at ml1.co.uk> wrote:

> Hopefully a quick question...

Hah, not likely :)

> Is there an easy way to count how many idle cycles a x86 CPU suffers for
> real application code due to memory bandwidth limits?
>
> That is, how to determine what percentage performance is lost due to the
> CPU having to wait for memory accesses?

This isn't quite what you've talking about, but try cachegrind /
callgrind (more valgrind love!). From
http://valgrind.org/info/tools.html#cachegrind :

"Cachegrind is a cache profiler. It performs detailed simulation of
the I1, D1 and L2 caches in your CPU and so can accurately pinpoint
the sources of cache misses in your code. It identifies the number of
cache misses, memory references and instructions executed for each
line of source code, with per-function, per-module and whole-program
summaries. It is useful with programs written in any language.
Cachegrind runs programs about 20--100x slower than normal."

Something else that is completely unrelated to what you're asking, but
still quite interesting is the contents of
/proc/acpi/processor/CPU0/power For me this gives something like:

active state:            C2
max_cstate:              C8
bus master activity:     00200000
states:
    C1:                  type[C1] promotion[C2] demotion[--]
latency[000] usage[56292390] duration[00000000000000000000]
   *C2:                  type[C2] promotion[--] demotion[C1]
latency[090] usage[319309907] duration[00000008893975587947]

The bit I'm interested in is the "states" part. If you've got a
reasonably modern processor it'll probably have multiple lower power
states and the bit above tells you where your processor is spending
time. C2 is the lower power state here and you can see that there's a
latency to get out of that state into the higher one (or something
along those line, I'm sure someone will tell me if I'm wrong). The
vast majority of time for this processor (a Via C3) is spent in the
low power mode If you have more than one C state and your processor is
spending all of its time in C1, then you probably want to have a look
at it.

That's enough of that for the mo anyway - must dash to the pub!

Cheers,

Roger



More information about the Nottingham mailing list