OSDN Git Service

Perfprofd: Minor fixes
authorAndreas Gampe <agampe@google.com>
Mon, 30 Apr 2018 23:55:15 +0000 (16:55 -0700)
committerAndreas Gampe <agampe@google.com>
Thu, 3 May 2018 20:34:39 +0000 (13:34 -0700)
Set the allowed minimum for collection_interval to 0.

Copy the sampling_frequency.

Add "-m 8192" when call-stacks are requested.

(cherry picked from commit 59a18215031faedc4bbee70baef363299cec0b69)

Bug: 73175642
Test: mmma system/extras/perfprofd
Test: perfprofd_test
Merged-In: I8fd41da08eb14dadc98b85afe1e4dbed2d9bc9b1
Change-Id: I8fd41da08eb14dadc98b85afe1e4dbed2d9bc9b1

perfprofd/configreader.cc
perfprofd/perfprofdcore.cc
perfprofd/tests/perfprofd_test.cc

index f2b6078..def3f18 100644 (file)
@@ -70,7 +70,7 @@ void ConfigReader::addDefaultEntries()
   // set to 100, then over time we want to see a perf profile
   // collected every 100 seconds). The actual time within the interval
   // for the collection is chosen randomly.
-  addUnsignedEntry("collection_interval", config.collection_interval_in_s, 1, UINT32_MAX);
+  addUnsignedEntry("collection_interval", config.collection_interval_in_s, 0, UINT32_MAX);
 
   // Use the specified fixed seed for random number generation (unit
   // testing)
@@ -337,6 +337,7 @@ void ConfigReader::FillConfig(Config* config) {
   config->perf_path = getStringValue("perf_path");
 
   config->sampling_period = getUnsignedValue("sampling_period");
+  config->sampling_frequency = getUnsignedValue("sampling_frequency");
 
   config->sample_duration_in_s = getUnsignedValue("sample_duration");
 
index c5605ac..73332a3 100644 (file)
@@ -481,7 +481,7 @@ static PROFILE_RESULT invoke_perf(Config& config,
     }
 
     // marshall arguments
-    constexpr unsigned max_args = 15;
+    constexpr unsigned max_args = 17;
     const char *argv[max_args];
     unsigned slot = 0;
     argv[slot++] = perf_path.c_str();
@@ -504,8 +504,11 @@ static PROFILE_RESULT invoke_perf(Config& config,
     }
 
     // -g if desired
-    if (stack_profile_opt)
+    if (stack_profile_opt) {
       argv[slot++] = stack_profile_opt;
+      argv[slot++] = "-m";
+      argv[slot++] = "8192";
+    }
 
     std::string pid_str;
     if (config.process < 0) {
index 6c5c278..a96fd71 100644 (file)
@@ -613,7 +613,6 @@ TEST_F(PerfProfdTest, ConfigFileParsing)
   runner.addToConfig("destination_directory=/does/not/exist");
 
   // assorted bad syntax
-  runner.addToConfig("collection_interval=0");
   runner.addToConfig("collection_interval=-1");
   runner.addToConfig("nonexistent_key=something");
   runner.addToConfig("no_equals_stmt");
@@ -626,10 +625,9 @@ TEST_F(PerfProfdTest, ConfigFileParsing)
 
   // Verify log contents
   const std::string expected = RAW_RESULT(
-      W: line 6: specified value 0 for 'collection_interval' outside permitted range [1 4294967295] (ignored)
-      W: line 7: malformed unsigned value (ignored)
-      W: line 8: unknown option 'nonexistent_key' ignored
-      W: line 9: line malformed (no '=' found)
+      W: line 6: malformed unsigned value (ignored)
+      W: line 7: unknown option 'nonexistent_key' ignored
+      W: line 8: line malformed (no '=' found)
                                           );
 
   // check to make sure log excerpt matches