linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* perf: counter and event question
@ 2009-12-28 11:16 Tim Blechmann
  2009-12-28 11:26 ` Peter Zijlstra
  0 siblings, 1 reply; 6+ messages in thread
From: Tim Blechmann @ 2009-12-28 11:16 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 962 bytes --]

hi all,

trying to use the perf subsystem, i am a bit confused by the terms
`performance counter' and `performance event'.

i am trying to compare `counting' counters with `sampling' counters. as
a test case, i am counting PERF_COUNT_HW_INSTRUCTIONS of the same code
piece with both approaches. the sampling counters are sampled with a
period of 1. the code is really trivial [1].

the `counting' counters report numbers of about 9000 instructions, but
the mmap buffer only seems to contain about 100 to 200 event samples.
from my (limited) understanding, these number should at least be
similar, so i am a bit confused to see such a big difference. am i
missing something, like it is impossible to sample instructions with a
period of 1? or could there be an issue with my code?

thanks, tim

[1] http://tim.klingt.org/git?p=perf-cpp.git

-- 
tim@klingt.org
http://tim.klingt.org

I don't write music for sissy ears.
  Charles Ives


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: perf: counter and event question
  2009-12-28 11:16 perf: counter and event question Tim Blechmann
@ 2009-12-28 11:26 ` Peter Zijlstra
  2009-12-28 12:39   ` Tim Blechmann
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2009-12-28 11:26 UTC (permalink / raw)
  To: Tim Blechmann; +Cc: linux-kernel

On Mon, 2009-12-28 at 12:16 +0100, Tim Blechmann wrote:
> like it is impossible to sample instructions with a period of 1? 

Pretty much, imagine the cpu getting a trap every cycle.

In order to avoid the machine grinding to a halt, we've implemented a
throttle which defaults to 100k samples/s, anything over that will be
discarted.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: perf: counter and event question
  2009-12-28 11:26 ` Peter Zijlstra
@ 2009-12-28 12:39   ` Tim Blechmann
  2009-12-28 13:03     ` Peter Zijlstra
  0 siblings, 1 reply; 6+ messages in thread
From: Tim Blechmann @ 2009-12-28 12:39 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 819 bytes --]

On 12/28/2009 12:26 PM, Peter Zijlstra wrote:
> On Mon, 2009-12-28 at 12:16 +0100, Tim Blechmann wrote:
>> like it is impossible to sample instructions with a period of 1? 
> 
> Pretty much, imagine the cpu getting a trap every cycle.

is this a hardware restriction? a slowdown is acceptable for me, as long
as i am able to collect a huge number of samples accurately ...

> In order to avoid the machine grinding to a halt, we've implemented a
> throttle which defaults to 100k samples/s, anything over that will be
> discarted.

i just found the proc interface for perf_event_max_sample_rate ... it
would be nice to have a short section on the event throttling in
tools/perf/design.txt ...

thanks, tim

-- 
tim@klingt.org
http://tim.klingt.org

art is short - life is long
  Jack Kerouac


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: perf: counter and event question
  2009-12-28 12:39   ` Tim Blechmann
@ 2009-12-28 13:03     ` Peter Zijlstra
  2009-12-28 13:09       ` Tim Blechmann
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Zijlstra @ 2009-12-28 13:03 UTC (permalink / raw)
  To: Tim Blechmann; +Cc: linux-kernel

On Mon, 2009-12-28 at 13:39 +0100, Tim Blechmann wrote:
> On 12/28/2009 12:26 PM, Peter Zijlstra wrote:
> > On Mon, 2009-12-28 at 12:16 +0100, Tim Blechmann wrote:
> >> like it is impossible to sample instructions with a period of 1? 
> > 
> > Pretty much, imagine the cpu getting a trap every cycle.
> 
> is this a hardware restriction? a slowdown is acceptable for me, as long
> as i am able to collect a huge number of samples accurately ...

Large number of samples and sample interval are only related through the
runtime of your application.

Use a sensible period (~10k ins) and run a 'little' longer.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: perf: counter and event question
  2009-12-28 13:03     ` Peter Zijlstra
@ 2009-12-28 13:09       ` Tim Blechmann
  2009-12-28 14:02         ` Peter Zijlstra
  0 siblings, 1 reply; 6+ messages in thread
From: Tim Blechmann @ 2009-12-28 13:09 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 977 bytes --]

>>>> like it is impossible to sample instructions with a period of 1? 
>>>
>>> Pretty much, imagine the cpu getting a trap every cycle.
>>
>> is this a hardware restriction? a slowdown is acceptable for me, as long
>> as i am able to collect a huge number of samples accurately ...
> 
> Large number of samples and sample interval are only related through the
> runtime of your application.
> 
> Use a sensible period (~10k ins) and run a 'little' longer.

well, for my application, i am not interested in statistical data, but
in the order of the events ...
(i am not doing profiling, but trying to gather a sequence of
machine-structured data for an artistic project)

tim

-- 
tim@klingt.org
http://tim.klingt.org

It is better to make a piece of music than to perform one, better to
perform one than to listen to one, better to listen to one than to
misuse it as a means of distraction, entertainment, or acquisition of
'culture'.
  John Cage


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: perf: counter and event question
  2009-12-28 13:09       ` Tim Blechmann
@ 2009-12-28 14:02         ` Peter Zijlstra
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Zijlstra @ 2009-12-28 14:02 UTC (permalink / raw)
  To: Tim Blechmann; +Cc: linux-kernel

On Mon, 2009-12-28 at 14:09 +0100, Tim Blechmann wrote:
> >>>> like it is impossible to sample instructions with a period of 1? 
> >>>
> >>> Pretty much, imagine the cpu getting a trap every cycle.
> >>
> >> is this a hardware restriction? a slowdown is acceptable for me, as long
> >> as i am able to collect a huge number of samples accurately ...
> > 
> > Large number of samples and sample interval are only related through the
> > runtime of your application.
> > 
> > Use a sensible period (~10k ins) and run a 'little' longer.
> 
> well, for my application, i am not interested in statistical data, but
> in the order of the events ...
> (i am not doing profiling, but trying to gather a sequence of
> machine-structured data for an artistic project)

Well, then use the branch tracer, that will give you the relation
between blocks of code and is actually doable.

But I guess you could hack out the throttle and run the cycle counter
with period=1 for userspace only.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-12-28 14:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-28 11:16 perf: counter and event question Tim Blechmann
2009-12-28 11:26 ` Peter Zijlstra
2009-12-28 12:39   ` Tim Blechmann
2009-12-28 13:03     ` Peter Zijlstra
2009-12-28 13:09       ` Tim Blechmann
2009-12-28 14:02         ` Peter Zijlstra

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).