summaryrefslogtreecommitdiffstats
path: root/runtime/jit
diff options
context:
space:
mode:
authorCalin Juravle <calin@google.com>2018-05-03 22:28:03 -0700
committerCalin Juravle <calin@google.com>2018-05-08 00:18:34 +0000
commitb3d1eeed7426570f61a0b0d4be1a2987200311f6 (patch)
treeab6d525a4fe1e54645fb6828916f1ad602ca5ea6 /runtime/jit
parent9926e4615d75cb6c9371e1766a14b0a80089ae18 (diff)
downloadart-b3d1eeed7426570f61a0b0d4be1a2987200311f6.tar.gz
art-b3d1eeed7426570f61a0b0d4be1a2987200311f6.tar.bz2
art-b3d1eeed7426570f61a0b0d4be1a2987200311f6.zip
Add new profile saver options: save without jit & profile AOT code
--Xps-save-without-jit-notifications The hotness for system server code is increased in AOT-ed code. The flow does not call into JIT and as such notifications are not triggered. Instead of relying on the JIT system, make use of a simple back off strategy to save the profile. --Xps-profile-aot-code Starts the profile saver even if the oat file is speed compiled. Test: m test-art-host boot a device with system server profiling enabled. Bug: 73313191 Change-Id: I66ec422a76bc9244349da7a5d18a3df5bcc9ccb7
Diffstat (limited to 'runtime/jit')
-rw-r--r--runtime/jit/jit.h7
-rw-r--r--runtime/jit/profile_saver.cc24
-rw-r--r--runtime/jit/profile_saver_options.h30
3 files changed, 54 insertions, 7 deletions
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index 6d27cfe5db..4b8b8919d1 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -252,6 +252,13 @@ class JitOptions {
void SetSaveProfilingInfo(bool save_profiling_info) {
profile_saver_options_.SetEnabled(save_profiling_info);
}
+ void SetWaitForJitNotificationsToSaveProfile(bool value) {
+ profile_saver_options_.SetWaitForJitNotificationsToSave(value);
+ }
+ void SetProfileAOTCode(bool value) {
+ profile_saver_options_.SetProfileAOTCode(value);
+ }
+
void SetJitAtFirstUse() {
use_jit_compilation_ = true;
compile_threshold_ = 0;
diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc
index 618fde8f00..efa8a4d2d5 100644
--- a/runtime/jit/profile_saver.cc
+++ b/runtime/jit/profile_saver.cc
@@ -131,6 +131,11 @@ void ProfileSaver::Run() {
}
FetchAndCacheResolvedClassesAndMethods(/*startup*/ true);
+
+ // When we save without waiting for JIT notifications we use a simple
+ // exponential back off policy bounded by max_wait_without_jit.
+ uint32_t max_wait_without_jit = options_.GetMinSavePeriodMs() * 16;
+ uint64_t cur_wait_without_jit = options_.GetMinSavePeriodMs();
// Loop for the profiled methods.
while (!ShuttingDown(self)) {
uint64_t sleep_start = NanoTime();
@@ -138,7 +143,14 @@ void ProfileSaver::Run() {
uint64_t sleep_time = 0;
{
MutexLock mu(self, wait_lock_);
- period_condition_.Wait(self);
+ if (options_.GetWaitForJitNotificationsToSave()) {
+ period_condition_.Wait(self);
+ } else {
+ period_condition_.TimedWait(self, cur_wait_without_jit, 0);
+ if (cur_wait_without_jit < max_wait_without_jit) {
+ cur_wait_without_jit *= 2;
+ }
+ }
sleep_time = NanoTime() - sleep_start;
}
// Check if the thread was woken up for shutdown.
@@ -597,7 +609,13 @@ void* ProfileSaver::RunProfileSaverThread(void* arg) {
return nullptr;
}
-static bool ShouldProfileLocation(const std::string& location) {
+static bool ShouldProfileLocation(const std::string& location, bool profile_aot_code) {
+ if (profile_aot_code) {
+ // If we have to profile all the code, irrespective of its compilation state, return true
+ // right away.
+ return true;
+ }
+
OatFileManager& oat_manager = Runtime::Current()->GetOatFileManager();
const OatFile* oat_file = oat_manager.FindOpenedOatFileFromDexLocation(location);
if (oat_file == nullptr) {
@@ -629,7 +647,7 @@ void ProfileSaver::Start(const ProfileSaverOptions& options,
std::vector<std::string> code_paths_to_profile;
for (const std::string& location : code_paths) {
- if (ShouldProfileLocation(location)) {
+ if (ShouldProfileLocation(location, options.GetProfileAOTCode())) {
code_paths_to_profile.push_back(location);
}
}
diff --git a/runtime/jit/profile_saver_options.h b/runtime/jit/profile_saver_options.h
index d1e14e2766..18f7899af1 100644
--- a/runtime/jit/profile_saver_options.h
+++ b/runtime/jit/profile_saver_options.h
@@ -41,7 +41,9 @@ struct ProfileSaverOptions {
min_notification_before_wake_(kMinNotificationBeforeWake),
max_notification_before_wake_(kMaxNotificationBeforeWake),
profile_path_(""),
- profile_boot_class_path_(false) {}
+ profile_boot_class_path_(false),
+ profile_aot_code_(false),
+ wait_for_jit_notifications_to_save_(true) {}
ProfileSaverOptions(
bool enabled,
@@ -53,7 +55,9 @@ struct ProfileSaverOptions {
uint32_t min_notification_before_wake,
uint32_t max_notification_before_wake,
const std::string& profile_path,
- bool profile_boot_class_path)
+ bool profile_boot_class_path,
+ bool profile_aot_code = false,
+ bool wait_for_jit_notifications_to_save = true)
: enabled_(enabled),
min_save_period_ms_(min_save_period_ms),
save_resolved_classes_delay_ms_(save_resolved_classes_delay_ms),
@@ -63,7 +67,9 @@ struct ProfileSaverOptions {
min_notification_before_wake_(min_notification_before_wake),
max_notification_before_wake_(max_notification_before_wake),
profile_path_(profile_path),
- profile_boot_class_path_(profile_boot_class_path) {}
+ profile_boot_class_path_(profile_boot_class_path),
+ profile_aot_code_(profile_aot_code),
+ wait_for_jit_notifications_to_save_(wait_for_jit_notifications_to_save) {}
bool IsEnabled() const {
return enabled_;
@@ -103,6 +109,18 @@ struct ProfileSaverOptions {
bool GetProfileBootClassPath() const {
return profile_boot_class_path_;
}
+ bool GetProfileAOTCode() const {
+ return profile_aot_code_;
+ }
+ void SetProfileAOTCode(bool value) {
+ profile_aot_code_ = value;
+ }
+ bool GetWaitForJitNotificationsToSave() const {
+ return wait_for_jit_notifications_to_save_;
+ }
+ void SetWaitForJitNotificationsToSave(bool value) {
+ wait_for_jit_notifications_to_save_ = value;
+ }
friend std::ostream & operator<<(std::ostream &os, const ProfileSaverOptions& pso) {
os << "enabled_" << pso.enabled_
@@ -113,7 +131,9 @@ struct ProfileSaverOptions {
<< ", min_classes_to_save_" << pso.min_classes_to_save_
<< ", min_notification_before_wake_" << pso.min_notification_before_wake_
<< ", max_notification_before_wake_" << pso.max_notification_before_wake_
- << ", profile_boot_class_path_" << pso.profile_boot_class_path_;
+ << ", profile_boot_class_path_" << pso.profile_boot_class_path_
+ << ", profile_aot_code_" << pso.profile_aot_code_
+ << ", wait_for_jit_notifications_to_save_" << pso.wait_for_jit_notifications_to_save_;
return os;
}
@@ -129,6 +149,8 @@ struct ProfileSaverOptions {
uint32_t max_notification_before_wake_;
std::string profile_path_;
bool profile_boot_class_path_;
+ bool profile_aot_code_;
+ bool wait_for_jit_notifications_to_save_;
};
} // namespace art