Add a new type of profile data in ART profiler
This CL allows the ART profiler to collect bounded stack information
that contains only method signature and dex pc on the current stack
frames to a bounded depth. The type of the profile data is by
default disabled, and can be enabled by setting the option
"-Xprofile-type:stack". The bound is controlled by the option
"-Xprofile-max-stack-depth:integervalue".
Change-Id: Ieab789951018b2263c4d140b40b6c73bffc6a549
diff --git a/runtime/profiler_options.h b/runtime/profiler_options.h
index 0b63003..e3ef697 100644
--- a/runtime/profiler_options.h
+++ b/runtime/profiler_options.h
@@ -24,7 +24,7 @@
enum ProfileDataType {
kProfilerMethod, // Method only
- kProfilerMethodAndDexPC, // Method with Dex PC
+ kProfilerBoundedStack, // Methods with Dex PC on top of the stack
};
class ProfilerOptions {
@@ -38,6 +38,7 @@
static constexpr double kDefaultTopKThreshold = 90.0;
static constexpr double kDefaultChangeInTopKThreshold = 10.0;
static constexpr ProfileDataType kDefaultProfileData = kProfilerMethod;
+ static constexpr uint32_t kDefaultMaxStackDepth = 3;
ProfilerOptions() :
enabled_(kDefaultEnabled),
@@ -48,7 +49,8 @@
start_immediately_(kDefaultStartImmediately),
top_k_threshold_(kDefaultTopKThreshold),
top_k_change_threshold_(kDefaultChangeInTopKThreshold),
- profile_type_(kDefaultProfileData) {}
+ profile_type_(kDefaultProfileData),
+ max_stack_depth_(kDefaultMaxStackDepth) {}
ProfilerOptions(bool enabled,
uint32_t period_s,
@@ -58,7 +60,8 @@
bool start_immediately,
double top_k_threshold,
double top_k_change_threshold,
- ProfileDataType profile_type):
+ ProfileDataType profile_type,
+ uint32_t max_stack_depth):
enabled_(enabled),
period_s_(period_s),
duration_s_(duration_s),
@@ -67,7 +70,8 @@
start_immediately_(start_immediately),
top_k_threshold_(top_k_threshold),
top_k_change_threshold_(top_k_change_threshold),
- profile_type_(profile_type) {}
+ profile_type_(profile_type),
+ max_stack_depth_(max_stack_depth) {}
bool IsEnabled() const {
return enabled_;
@@ -105,6 +109,10 @@
return profile_type_;
}
+ uint32_t GetMaxStackDepth() const {
+ return max_stack_depth_;
+ }
+
private:
friend std::ostream & operator<<(std::ostream &os, const ProfilerOptions& po) {
os << "enabled=" << po.enabled_
@@ -115,7 +123,8 @@
<< ", start_immediately=" << po.start_immediately_
<< ", top_k_threshold=" << po.top_k_threshold_
<< ", top_k_change_threshold=" << po.top_k_change_threshold_
- << ", profile_type=" << po.profile_type_;
+ << ", profile_type=" << po.profile_type_
+ << ", max_stack_depth=" << po.max_stack_depth_;
return os;
}
@@ -139,6 +148,8 @@
double top_k_change_threshold_;
// The type of profile data dumped to the disk.
ProfileDataType profile_type_;
+ // The max depth of the stack collected by the profiler
+ uint32_t max_stack_depth_;
};
} // namespace art