summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2014-04-07 18:07:43 +0300
committerCalin Juravle <calin@google.com>2014-04-07 19:05:25 +0300
commit1659006728b929aa820d09bdaba58b462cc8e7cc (patch)
treecb1af26e2be04682d6b1359c26598f65342182eb
parent5cc2d076cb7854ec2327895e5586f4cbe5e3ee70 (diff)
downloadart-1659006728b929aa820d09bdaba58b462cc8e7cc.zip
art-1659006728b929aa820d09bdaba58b462cc8e7cc.tar.gz
art-1659006728b929aa820d09bdaba58b462cc8e7cc.tar.bz2
Profile: made startImmediately settable
By default the profiler starts immediately upon app startup. To delay the startup by some random offset use -Xprofile-start_lazy. Bug: 12877748 Change-Id: Ifc1bb7f79f9f9aa53204b2fb1fbae3cd5c780cac
-rw-r--r--runtime/parsed_options.cc3
-rw-r--r--runtime/parsed_options.h1
-rw-r--r--runtime/runtime.cc9
-rw-r--r--runtime/runtime.h4
4 files changed, 12 insertions, 5 deletions
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc
index 08a674f..bc8f51f 100644
--- a/runtime/parsed_options.cc
+++ b/runtime/parsed_options.cc
@@ -194,6 +194,7 @@ bool ParsedOptions::Parse(const Runtime::Options& options, bool ignore_unrecogni
profile_duration_s_ = 20; // Seconds.
profile_interval_us_ = 500; // Microseconds.
profile_backoff_coefficient_ = 2.0;
+ profile_start_immediately_ = true;
profile_clock_source_ = kDefaultProfilerClockSource;
verify_ = true;
@@ -509,6 +510,8 @@ bool ParsedOptions::Parse(const Runtime::Options& options, bool ignore_unrecogni
if (!ParseDouble(option, ':', 1.0, 10.0, &profile_backoff_coefficient_)) {
return false;
}
+ } else if (option == "-Xprofile-start-lazy") {
+ profile_start_immediately_ = false;
} else if (StartsWith(option, "-implicit-checks:")) {
std::string checks;
if (!ParseStringAfterChar(option, ':', &checks)) {
diff --git a/runtime/parsed_options.h b/runtime/parsed_options.h
index 416bc78..126096a 100644
--- a/runtime/parsed_options.h
+++ b/runtime/parsed_options.h
@@ -79,6 +79,7 @@ class ParsedOptions {
uint32_t profile_duration_s_;
uint32_t profile_interval_us_;
double profile_backoff_coefficient_;
+ bool profile_start_immediately_;
ProfilerClockSource profile_clock_source_;
bool verify_;
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 1b3c996..3c23855 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -121,6 +121,7 @@ Runtime::Runtime()
profile_duration_s_(0),
profile_interval_us_(0),
profile_backoff_coefficient_(0),
+ profile_start_immediately_(true),
method_trace_(false),
method_trace_file_size_(0),
instrumentation_(),
@@ -392,7 +393,7 @@ bool Runtime::Start() {
if (fd >= 0) {
close(fd);
}
- StartProfiler(profile_output_filename_.c_str(), "", true);
+ StartProfiler(profile_output_filename_.c_str(), "");
}
return true;
@@ -617,6 +618,7 @@ bool Runtime::Init(const Options& raw_options, bool ignore_unrecognized) {
profile_duration_s_ = options->profile_duration_s_;
profile_interval_us_ = options->profile_interval_us_;
profile_backoff_coefficient_ = options->profile_backoff_coefficient_;
+ profile_start_immediately_ = options->profile_start_immediately_;
profile_ = options->profile_;
profile_output_filename_ = options->profile_output_filename_;
// TODO: move this to just be an Trace::Start argument
@@ -1144,10 +1146,9 @@ void Runtime::RemoveMethodVerifier(verifier::MethodVerifier* verifier) {
method_verifiers_.erase(it);
}
-void Runtime::StartProfiler(const char* appDir, const char* procName, bool startImmediately) {
+void Runtime::StartProfiler(const char* appDir, const char* procName) {
BackgroundMethodSamplingProfiler::Start(profile_period_s_, profile_duration_s_, appDir,
- procName, profile_interval_us_,
- profile_backoff_coefficient_, startImmediately);
+ procName, profile_interval_us_, profile_backoff_coefficient_, profile_start_immediately_);
}
// Transaction support.
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 7b3e04c..9e6bd2a 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -374,7 +374,7 @@ class Runtime {
const std::vector<const DexFile*>& GetCompileTimeClassPath(jobject class_loader);
void SetCompileTimeClassPath(jobject class_loader, std::vector<const DexFile*>& class_path);
- void StartProfiler(const char* appDir, const char* procName, bool startImmediately = false);
+ void StartProfiler(const char* appDir, const char* procName);
void UpdateProfilerState(int state);
// Transaction support.
@@ -542,6 +542,8 @@ class Runtime {
uint32_t profile_duration_s_; // Run profile for n seconds.
uint32_t profile_interval_us_; // Microseconds between samples.
double profile_backoff_coefficient_; // Coefficient to exponential backoff.
+ bool profile_start_immediately_; // Whether the profile should start upon app
+ // startup or be delayed by some random offset.
bool method_trace_;
std::string method_trace_file_;