Details:
- turn "max unprocessed profiles" into a configurable parameter.
- use a longer default collection interval
- reread config file on very iteration through the main loop,
so as to incorporate new parameters written by the upload service
Bug: http://b/
19483574
Change-Id: I1ecacbdeccf26f09ddd8387aef0f2587483eb967
(cherry picked from commit
f353d8bf370eab2117e6259630f5540f12b361b0)
"/data/data/com.google.android.gms/files/perfprofd.conf";
//
"/data/data/com.google.android.gms/files/perfprofd.conf";
//
-// Set by SIGHUP signal handler
-//
-volatile unsigned please_reread_config_file = 0;
-
-//
// This table describes the config file syntax in terms of key/value pairs.
// Values come in two flavors: strings, or unsigned integers. In the latter
// case the reader sets allowable minimum/maximum for the setting.
// This table describes the config file syntax in terms of key/value pairs.
// Values come in two flavors: strings, or unsigned integers. In the latter
// case the reader sets allowable minimum/maximum for the setting.
std::string getStringValue(const char *key) const;
// read the specified config file, applying any settings it contains
std::string getStringValue(const char *key) const;
// read the specified config file, applying any settings it contains
+ void readFile(bool initial);
private:
void addUnsignedEntry(const char *key,
private:
void addUnsignedEntry(const char *key,
// 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.
// 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", 901, 100, UINT32_MAX);
+ addUnsignedEntry("collection_interval", 14400, 100, UINT32_MAX);
// Use the specified fixed seed for random number generation (unit
// testing)
// Use the specified fixed seed for random number generation (unit
// testing)
addUnsignedEntry("hardwire_cpus", 1, 0, 1);
addUnsignedEntry("hardwire_cpus_max_duration", 5, 1, UINT32_MAX);
addUnsignedEntry("hardwire_cpus", 1, 0, 1);
addUnsignedEntry("hardwire_cpus_max_duration", 5, 1, UINT32_MAX);
+ // Maximum number of unprocessed profiles we can accumulate in the
+ // destination directory. Once we reach this limit, we continue
+ // to collect, but we just overwrite the most recent profile.
+ addUnsignedEntry("max_unprocessed_profiles", 10, 1, UINT32_MAX);
+
// If set to 1, pass the -g option when invoking 'perf' (requests
// stack traces as opposed to flat profile).
addUnsignedEntry("stack_profile", 0, 0, 1);
// If set to 1, pass the -g option when invoking 'perf' (requests
// stack traces as opposed to flat profile).
addUnsignedEntry("stack_profile", 0, 0, 1);
-void ConfigReader::readFile()
+void ConfigReader::readFile(bool initial)
{
FILE *fp = fopen(config_file_path, "r");
if (!fp) {
{
FILE *fp = fopen(config_file_path, "r");
if (!fp) {
- W_ALOGE("unable to open configuration file %s", config_file_path);
+ if (initial) {
+ W_ALOGE("unable to open configuration file %s", config_file_path);
+ }
+ } else {
+ W_ALOGW("unable to open destination dir %s for cleanup",
+ dest_dir.c_str());
- if (produced.size() >= MAX_UNPROCESSED_FILE) {
+ unsigned maxLive = config.getUnsignedValue("max_unprocessed_profiles");
+ if (produced.size() >= maxLive) {
-// SIGHUP handler. Sets a flag to indicate that we should reread the
-// config file
+// SIGHUP handler. Sending SIGHUP to the daemon can be used to break it
+// out of a sleep() call so as to trigger a new collection (debugging)
//
static void sig_hup(int /* signum */)
{
//
static void sig_hup(int /* signum */)
{
- please_reread_config_file = 1;
//
static void init(ConfigReader &config)
{
//
static void init(ConfigReader &config)
{
set_seed(config);
cleanup_destination_dir(config);
set_seed(config);
cleanup_destination_dir(config);
config.getUnsignedValue("collection_interval"));
perfprofd_sleep(sleep_before_collect);
config.getUnsignedValue("collection_interval"));
perfprofd_sleep(sleep_before_collect);
- // Reread config file if someone sent a SIGHUP
- if (please_reread_config_file) {
- config.readFile();
- please_reread_config_file = 0;
- }
+ // Reread config file -- the uploader may have rewritten it as a result
+ // of a gservices change
+ config.readFile(false);
// Check for profiling enabled...
CKPROFILE_RESULT ckresult = check_profiling_enabled(config);
// Check for profiling enabled...
CKPROFILE_RESULT ckresult = check_profiling_enabled(config);
// by perfprofd within the destination directory; consumed by GmsCore.
#define PRODUCED_FILENAME "perfprofd_produced.txt"
// by perfprofd within the destination directory; consumed by GmsCore.
#define PRODUCED_FILENAME "perfprofd_produced.txt"
-// Maximum number of encoded perf.data files stored in destination dir
-#define MAX_UNPROCESSED_FILE 10
-
// Main routine for perfprofd daemon
extern int perfprofd_main(int argc, char **argv);
// Main routine for perfprofd daemon
extern int perfprofd_main(int argc, char **argv);
//
PerfProfdRunner runner;
runner.addToConfig("only_debug_build=0");
//
PerfProfdRunner runner;
runner.addToConfig("only_debug_build=0");
- runner.addToConfig("trace_config_read=1");
+ runner.addToConfig("trace_config_read=0");
runner.addToConfig("config_directory=/does/not/exist");
runner.addToConfig("main_loop_iterations=1");
runner.addToConfig("use_fixed_seed=1");
runner.addToConfig("config_directory=/does/not/exist");
runner.addToConfig("main_loop_iterations=1");
runner.addToConfig("use_fixed_seed=1");
runner.addToConfig(cfparam);
runner.addToConfig("main_loop_iterations=1");
runner.addToConfig("use_fixed_seed=12345678");
runner.addToConfig(cfparam);
runner.addToConfig("main_loop_iterations=1");
runner.addToConfig("use_fixed_seed=12345678");
+ runner.addToConfig("max_unprocessed_profiles=100");
runner.addToConfig("collection_interval=9999");
runner.addToConfig("sample_duration=2");
runner.addToConfig("collection_interval=9999");
runner.addToConfig("sample_duration=2");