linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Milian Wolff <milian.wolff@kdab.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: deducing CPU clock rate over time from cycle samples
Date: Sat, 17 Jun 2017 21:22:19 -0700	[thread overview]
Message-ID: <87efuivsas.fsf@firstfloor.org> (raw)
In-Reply-To: <2900948.aeNJFYEL58@agathebauer> (Milian Wolff's message of "Sat, 17 Jun 2017 21:07:36 +0200")

Milian Wolff <milian.wolff@kdab.com> writes:
>
> But when I look at the naively calculated first derivative, to visualize CPU 
> load, i.e. CPU clock rate in Hz, then things start to become somewhat 
> confusing:
>
> ~~~~
> perf script -F time,period | awk 'BEGIN {lastTime = -1;} { time = $1 + 0.0; if 
> (lastTime != -1) {printf("%.6f\t%f\n", time, $2 / (time - lastTime));} 
> lastTime = time; }' | gnuplot -p -e "plot '-' with linespoints"
> ~~~~

The perf time stamps approach the maximum precision of double (12 vs
15 digits). Likely the division loses too many digits, which may cause
the bogus results. I've ran into similar problems before.

One way around is is to normalize the time stamps first that they
start with 0, but this only works for shorter traces.
Or use some bignum float library

Also at the beginning of frequency the periods are very small, and
the default us resolution will give big jumps for such a calculation.
It's better to use the script --ns option then, but that makes the
double precision problem event worse.

In generally you get better results by avoiding frequency mode,
but always specify a fixed period. 

-Andi

  reply	other threads:[~2017-06-18  4:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-17 19:07 deducing CPU clock rate over time from cycle samples Milian Wolff
2017-06-18  4:22 ` Andi Kleen [this message]
2017-06-18 19:53   ` Milian Wolff
2017-08-28 14:08     ` broken cycle counts from perf record in frequency mode [Was: Re: deducing CPU clock rate over time from cycle samples] Milian Wolff
2017-08-28 14:40       ` Milian Wolff
2017-08-28 17:28         ` Andi Kleen
2017-09-01 10:34           ` Milian Wolff
2017-09-01 16:48             ` Andi Kleen
2017-09-04 14:35               ` Milian Wolff
2017-09-05  3:40                 ` Andi Kleen
2017-09-05 12:26                   ` Milian Wolff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87efuivsas.fsf@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=milian.wolff@kdab.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).