perf: counter and event question
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
Signature · 5 lines
[email protected] http://tim.klingt.org I don't write music for sissy ears. Charles Ives
Quoted 1 line · Tim Blechmann
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.
Quoted 4 lines · Peter Zijlstra
Quoted 1 line · Tim Blechmann
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 ...
Quoted 3 lines
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
Signature · 5 lines
[email protected] http://tim.klingt.org art is short - life is long Jack Kerouac
Quoted 8 lines · Tim Blechmann
Quoted 4 lines · Peter Zijlstra
Quoted 1 line · Tim Blechmann
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.
Quoted 11 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
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
Signature · 8 lines
[email protected] 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
Quoted 10 lines · Tim Blechmann
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
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.
Quoted 6 lines
Quoted 1 line
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.