Speed ​​setting for profiling a perforated sample

As I understand it, the Performance Counters for Linux subsystem uses the perf record command to perform selective profiling of the CPU and hardware counters (for example, cache misses).

  • How to determine the sampling rate for perf record ? The closest I see on the manual page is the somewhat cryptic option “-c, --count = period of the event to sample”, but it is unclear whether this refers to the period as the duration or the period of the backward course (and if the latter, which units he is expecting).

  • What is a “good” sample rate for an application on an Android mobile device? What speed is too low to be useful, and what speed is excessively high?

+4
source share
1 answer

First you need to get a list of events using perf list . I have no experience with Android, so if you can, please show the most interesting part of this list.

1) -c will be the countdown of the event between samples. (only the count'th event is counted, 1 is the selection, and 100000 is the selection of each 100000th event). if there is an event for cpu tick (smth like TSC), then counting the number of ticks, and I recommend that you set the sample to run no more than 1 millisecond. To get the number of tags, use the formula: CPU_Freq_in_MHz * 1000 . This is the number of events to receive a sample every milliseconds, for example. to use the 800 MHz processor and use the -c 800000 event.

For other events, you must evaluate how often they will do. If you do not know, you can start with the count value for ticks, and then check if enough samples have been collected. If not, reduce the score ten times and check again. An account for ticks will be safe, since the check mark is one of the most common events in any processor.

2) Good speed is different for different PMUs, which is selected with the option "-e" or "--event =". If the event is rare, no more than 1000 per second, you can even test every event. If the event looks like a cache miss, you should try several options, because a good value depends on the selected code. Too low a sampling rate will give you a small number of samples, and the results will not be reliable and noisy. But for too high speed, the results will also be tagged, because each PMU can affect the program being tracked. I recommend that you use no more than 1000 events per second on average.

+4
source

All Articles