blob: 18f7899af10b99958ca5d8c7004fe2db46cb94ad [file] [log] [blame]
Calin Juravle138dbff2016-06-28 19:36:58 +01001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 * * See the License for the specific language governing permissions and
10 * limitations under the License.
11 */
12
13#ifndef ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_
14#define ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_
15
Calin Juravle138dbff2016-06-28 19:36:58 +010016#include <ostream>
Andreas Gampe8cf9cb32017-07-19 09:28:38 -070017#include <string>
Calin Juravle138dbff2016-06-28 19:36:58 +010018
19namespace art {
20
21struct ProfileSaverOptions {
22 public:
Calin Juravle806843a2017-05-01 15:14:44 -070023 static constexpr uint32_t kMinSavePeriodMs = 40 * 1000; // 40 seconds
Mathieu Chartiercbb7cee2017-03-14 15:23:03 -070024 static constexpr uint32_t kSaveResolvedClassesDelayMs = 5 * 1000; // 5 seconds
Mathieu Chartier7b135c82017-06-05 12:54:01 -070025 // Minimum number of JIT samples during launch to mark a method as hot in the profile.
26 static constexpr uint32_t kHotStartupMethodSamples = 1;
Mathieu Chartier273d1102017-06-06 17:07:13 -070027 static constexpr uint32_t kHotStartupMethodSamplesLowRam = 256;
Calin Juravle138dbff2016-06-28 19:36:58 +010028 static constexpr uint32_t kMinMethodsToSave = 10;
29 static constexpr uint32_t kMinClassesToSave = 10;
30 static constexpr uint32_t kMinNotificationBeforeWake = 10;
31 static constexpr uint32_t kMaxNotificationBeforeWake = 50;
Mathieu Chartier273d1102017-06-06 17:07:13 -070032 static constexpr uint32_t kHotStartupMethodSamplesNotSet = std::numeric_limits<uint32_t>::max();
Calin Juravle138dbff2016-06-28 19:36:58 +010033
34 ProfileSaverOptions() :
35 enabled_(false),
36 min_save_period_ms_(kMinSavePeriodMs),
37 save_resolved_classes_delay_ms_(kSaveResolvedClassesDelayMs),
Mathieu Chartier273d1102017-06-06 17:07:13 -070038 hot_startup_method_samples_(kHotStartupMethodSamplesNotSet),
Calin Juravle138dbff2016-06-28 19:36:58 +010039 min_methods_to_save_(kMinMethodsToSave),
40 min_classes_to_save_(kMinClassesToSave),
41 min_notification_before_wake_(kMinNotificationBeforeWake),
Calin Juravle9545f6d2017-03-16 19:05:09 -070042 max_notification_before_wake_(kMaxNotificationBeforeWake),
Mathieu Chartier885a7132017-06-10 14:35:11 -070043 profile_path_(""),
Calin Juravleb3d1eee2018-05-03 22:28:03 -070044 profile_boot_class_path_(false),
45 profile_aot_code_(false),
46 wait_for_jit_notifications_to_save_(true) {}
Calin Juravle138dbff2016-06-28 19:36:58 +010047
48 ProfileSaverOptions(
49 bool enabled,
50 uint32_t min_save_period_ms,
51 uint32_t save_resolved_classes_delay_ms,
Mathieu Chartier7b135c82017-06-05 12:54:01 -070052 uint32_t hot_startup_method_samples,
Calin Juravle138dbff2016-06-28 19:36:58 +010053 uint32_t min_methods_to_save,
54 uint32_t min_classes_to_save,
55 uint32_t min_notification_before_wake,
Calin Juravle9545f6d2017-03-16 19:05:09 -070056 uint32_t max_notification_before_wake,
Mathieu Chartier885a7132017-06-10 14:35:11 -070057 const std::string& profile_path,
Calin Juravleb3d1eee2018-05-03 22:28:03 -070058 bool profile_boot_class_path,
59 bool profile_aot_code = false,
60 bool wait_for_jit_notifications_to_save = true)
Mathieu Chartier885a7132017-06-10 14:35:11 -070061 : enabled_(enabled),
Calin Juravle138dbff2016-06-28 19:36:58 +010062 min_save_period_ms_(min_save_period_ms),
63 save_resolved_classes_delay_ms_(save_resolved_classes_delay_ms),
Mathieu Chartier7b135c82017-06-05 12:54:01 -070064 hot_startup_method_samples_(hot_startup_method_samples),
Calin Juravle138dbff2016-06-28 19:36:58 +010065 min_methods_to_save_(min_methods_to_save),
66 min_classes_to_save_(min_classes_to_save),
67 min_notification_before_wake_(min_notification_before_wake),
Calin Juravle9545f6d2017-03-16 19:05:09 -070068 max_notification_before_wake_(max_notification_before_wake),
Mathieu Chartier885a7132017-06-10 14:35:11 -070069 profile_path_(profile_path),
Calin Juravleb3d1eee2018-05-03 22:28:03 -070070 profile_boot_class_path_(profile_boot_class_path),
71 profile_aot_code_(profile_aot_code),
72 wait_for_jit_notifications_to_save_(wait_for_jit_notifications_to_save) {}
Calin Juravle138dbff2016-06-28 19:36:58 +010073
74 bool IsEnabled() const {
75 return enabled_;
76 }
77 void SetEnabled(bool enabled) {
78 enabled_ = enabled;
79 }
80
81 uint32_t GetMinSavePeriodMs() const {
82 return min_save_period_ms_;
83 }
84 uint32_t GetSaveResolvedClassesDelayMs() const {
85 return save_resolved_classes_delay_ms_;
86 }
Mathieu Chartier273d1102017-06-06 17:07:13 -070087 uint32_t GetHotStartupMethodSamples(bool is_low_ram) const {
88 uint32_t ret = hot_startup_method_samples_;
89 if (ret == kHotStartupMethodSamplesNotSet) {
90 ret = is_low_ram ? kHotStartupMethodSamplesLowRam : kHotStartupMethodSamples;
91 }
92 return ret;
Calin Juravle138dbff2016-06-28 19:36:58 +010093 }
94 uint32_t GetMinMethodsToSave() const {
95 return min_methods_to_save_;
96 }
97 uint32_t GetMinClassesToSave() const {
98 return min_classes_to_save_;
99 }
100 uint32_t GetMinNotificationBeforeWake() const {
101 return min_notification_before_wake_;
102 }
103 uint32_t GetMaxNotificationBeforeWake() const {
104 return max_notification_before_wake_;
105 }
Calin Juravle9545f6d2017-03-16 19:05:09 -0700106 std::string GetProfilePath() const {
107 return profile_path_;
108 }
Mathieu Chartier885a7132017-06-10 14:35:11 -0700109 bool GetProfileBootClassPath() const {
110 return profile_boot_class_path_;
111 }
Calin Juravleb3d1eee2018-05-03 22:28:03 -0700112 bool GetProfileAOTCode() const {
113 return profile_aot_code_;
114 }
115 void SetProfileAOTCode(bool value) {
116 profile_aot_code_ = value;
117 }
118 bool GetWaitForJitNotificationsToSave() const {
119 return wait_for_jit_notifications_to_save_;
120 }
121 void SetWaitForJitNotificationsToSave(bool value) {
122 wait_for_jit_notifications_to_save_ = value;
123 }
Calin Juravle138dbff2016-06-28 19:36:58 +0100124
125 friend std::ostream & operator<<(std::ostream &os, const ProfileSaverOptions& pso) {
126 os << "enabled_" << pso.enabled_
127 << ", min_save_period_ms_" << pso.min_save_period_ms_
128 << ", save_resolved_classes_delay_ms_" << pso.save_resolved_classes_delay_ms_
Mathieu Chartier7b135c82017-06-05 12:54:01 -0700129 << ", hot_startup_method_samples_" << pso.hot_startup_method_samples_
Calin Juravle138dbff2016-06-28 19:36:58 +0100130 << ", min_methods_to_save_" << pso.min_methods_to_save_
131 << ", min_classes_to_save_" << pso.min_classes_to_save_
132 << ", min_notification_before_wake_" << pso.min_notification_before_wake_
Mathieu Chartier885a7132017-06-10 14:35:11 -0700133 << ", max_notification_before_wake_" << pso.max_notification_before_wake_
Calin Juravleb3d1eee2018-05-03 22:28:03 -0700134 << ", profile_boot_class_path_" << pso.profile_boot_class_path_
135 << ", profile_aot_code_" << pso.profile_aot_code_
136 << ", wait_for_jit_notifications_to_save_" << pso.wait_for_jit_notifications_to_save_;
Calin Juravle138dbff2016-06-28 19:36:58 +0100137 return os;
138 }
139
140 bool enabled_;
141 uint32_t min_save_period_ms_;
142 uint32_t save_resolved_classes_delay_ms_;
Mathieu Chartier273d1102017-06-06 17:07:13 -0700143 // Do not access hot_startup_method_samples_ directly for reading since it may be set to the
144 // placeholder default.
Mathieu Chartier7b135c82017-06-05 12:54:01 -0700145 uint32_t hot_startup_method_samples_;
Calin Juravle138dbff2016-06-28 19:36:58 +0100146 uint32_t min_methods_to_save_;
147 uint32_t min_classes_to_save_;
148 uint32_t min_notification_before_wake_;
149 uint32_t max_notification_before_wake_;
Calin Juravle9545f6d2017-03-16 19:05:09 -0700150 std::string profile_path_;
Mathieu Chartier885a7132017-06-10 14:35:11 -0700151 bool profile_boot_class_path_;
Calin Juravleb3d1eee2018-05-03 22:28:03 -0700152 bool profile_aot_code_;
153 bool wait_for_jit_notifications_to_save_;
Calin Juravle138dbff2016-06-28 19:36:58 +0100154};
155
156} // namespace art
157
158#endif // ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_