Re: Statistical theory behind OProfile

Andi Kleen <[email protected]>
Newsgroups gmane.linux.oprofile
Message-ID <[email protected]>
Donald Johnson <[email protected]> writes:

> I wanted to use oprofile and apply some statistical work while
> profiling some the programs I work on.  I'm wondering what the
> statistical theory and probably also computer science theory behind
> the program is.  There are two sources I've found on the subject that
> I can currently access.

If you find out please let me know. I always wondered about
a sound theory too. But some notes based on experience below.
>
> "A Randomized Sampling Clock for CPU Utilization Estimation and Code
> Profiling"[2] is a paper on the subject that I would like to find more
> material like it on, but I am terrible at traversing academia and the
> like.  It goes through the general process that statistical profiling
> is and what distributions it comes from, but more interestingly it
> specifies the bias that can arise from timers that do not have
> sufficient randomness attached to them.

The default periods are not randomized (but the events happening in the
workload may be). Some choice of periods can minimize bias though
(e.g. using primes)

> However, the article is 12
> years old, so the implementation details that produce bias may not
> apply.

The distribution depends on both the used event and the workload.
For example a workload that just runs the same loop over and over
has very different sampling characteristics, than a more varied workload
which runs many different kinds of short events.

Some events also depend on multiple workloads, for example
cache misses of shared caches in multi-core systems when the different
cores are running multiple loads.

Another factor is the sampling period, and how it related to the
frequency of workload changes (according to the sampling theorem)
>
> In short, I wondering what sort of behind-the-scenes process oprofile
> is statistically.  It just returns samples.  I'd like to know the
> distribution it would come from (which seems to be the Poisson
> distribution based on my sources) so I may gather some intuition from
> the output.  I also want to know if OProfile does its sampling in a
> manner that may introduce bias.

Yes it can introduce (sometimes serious) bias.

> The environment I am working on is an armv5 board, which means I have
> to use release 0.9.9 for software interrupts.

That's a very poor environment for performance monitoring. Better use
some system with a real PMU, where you can use event driven sampling,
which tends to be more accurate than time driven sampling.

-Andi

------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.