diff options
author | Andreas Gampe <agampe@google.com> | 2018-04-04 21:06:26 -0700 |
---|---|---|
committer | Andreas Gampe <agampe@google.com> | 2018-04-12 11:11:12 -0700 |
commit | b3ebfaaeef2fa5fd3f1071b0fe8b9b92edbbdd2d (patch) | |
tree | c945aa1cb8e85271a59dc9cdf6330da894d5bab4 | |
parent | 0708cde464d97fc0a1b251f0431f6fe29f07b47d (diff) | |
download | extras-b3ebfaaeef2fa5fd3f1071b0fe8b9b92edbbdd2d.tar.gz |
Perfprofd: Add support for sampling frequency
Allow sampling frequency (-f) besides sampling period (-c), and
support simpleperf default values (when neither is set).
(cherry picked from commit e4b2ed98a9a4a35ac4bb46c20b1599e0889eb3a3)
Bug: 73175642
Test: mmma system/extras/perfprofd
Test: perfprofd_test
Merged-In: I40d7472bc45f5efd33687f9d8a5d6493343091c3
Change-Id: I40d7472bc45f5efd33687f9d8a5d6493343091c3
-rw-r--r-- | perfprofd/binder_interface/perfprofd_config.proto | 6 | ||||
-rw-r--r-- | perfprofd/config.h | 8 | ||||
-rw-r--r-- | perfprofd/configreader.cc | 4 | ||||
-rw-r--r-- | perfprofd/perfprofdcore.cc | 15 |
4 files changed, 25 insertions, 8 deletions
diff --git a/perfprofd/binder_interface/perfprofd_config.proto b/perfprofd/binder_interface/perfprofd_config.proto index c25aa93b..37c369c2 100644 --- a/perfprofd/binder_interface/perfprofd_config.proto +++ b/perfprofd/binder_interface/perfprofd_config.proto @@ -33,8 +33,12 @@ message ProfilingConfig { // Desired sampling period (passed to perf -c option). Small // sampling periods can perturb the collected profiles, so enforce - // min/max. + // min/max. A value of 0 means perf default. sampling_frequency + // takes priority. optional uint32 sampling_period = 7; + // Desired sampling frequency (passed to perf -f option). A value of 0 + // means using sampling_period or default. + optional uint32 sampling_frequency = 22; // Length of time to collect samples (number of seconds for 'perf // record -a' run). optional uint32 sample_duration_in_s = 8; diff --git a/perfprofd/config.h b/perfprofd/config.h index 774f7e86..0ee23099 100644 --- a/perfprofd/config.h +++ b/perfprofd/config.h @@ -52,8 +52,12 @@ struct Config { // Desired sampling period (passed to perf -c option). Small // sampling periods can perturb the collected profiles, so enforce - // min/max. - uint32_t sampling_period = 5000; + // min/max. A value of 0 means perf default. sampling_frequency + // takes priority. + uint32_t sampling_period = 0; + // Desired sampling frequency (passed to perf -f option). A value of 0 + // means using sampling_period or default. + uint32_t sampling_frequency = 0; // Length of time to collect samples (number of seconds for 'perf // record -a' run). uint32_t sample_duration_in_s = 2; diff --git a/perfprofd/configreader.cc b/perfprofd/configreader.cc index ac78f276..5d52b26e 100644 --- a/perfprofd/configreader.cc +++ b/perfprofd/configreader.cc @@ -91,7 +91,9 @@ void ConfigReader::addDefaultEntries() addStringEntry("perf_path", config.perf_path.c_str()); // Desired sampling period (passed to perf -c option). - addUnsignedEntry("sampling_period", config.sampling_period, 1, UINT32_MAX); + addUnsignedEntry("sampling_period", config.sampling_period, 0, UINT32_MAX); + // Desired sampling frequency (passed to perf -f option). + addUnsignedEntry("sampling_frequency", config.sampling_frequency, 0, UINT32_MAX); // Length of time to collect samples (number of seconds for 'perf // record -a' run). diff --git a/perfprofd/perfprofdcore.cc b/perfprofd/perfprofdcore.cc index 69508ad6..d7b0e9b4 100644 --- a/perfprofd/perfprofdcore.cc +++ b/perfprofd/perfprofdcore.cc @@ -491,10 +491,17 @@ static PROFILE_RESULT invoke_perf(Config& config, argv[slot++] = "-o"; argv[slot++] = data_file_path.c_str(); - // -c N - argv[slot++] = "-c"; - std::string p_str = android::base::StringPrintf("%u", sampling_period); - argv[slot++] = p_str.c_str(); + // -c/f N + std::string p_str; + if (config.sampling_frequency > 0) { + argv[slot++] = "-f"; + p_str = android::base::StringPrintf("%u", sampling_period); + argv[slot++] = p_str.c_str(); + } else if (config.sampling_period > 0) { + argv[slot++] = "-c"; + p_str = android::base::StringPrintf("%u", sampling_period); + argv[slot++] = p_str.c_str(); + } // -g if desired if (stack_profile_opt) |