Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 1 | /* |
| 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 | |
| 16 | #include <string> |
| 17 | #include <ostream> |
| 18 | |
| 19 | namespace art { |
| 20 | |
| 21 | struct ProfileSaverOptions { |
| 22 | public: |
Calin Juravle | 806843a | 2017-05-01 15:14:44 -0700 | [diff] [blame] | 23 | static constexpr uint32_t kMinSavePeriodMs = 40 * 1000; // 40 seconds |
Mathieu Chartier | cbb7cee | 2017-03-14 15:23:03 -0700 | [diff] [blame] | 24 | static constexpr uint32_t kSaveResolvedClassesDelayMs = 5 * 1000; // 5 seconds |
Mathieu Chartier | 7b135c8 | 2017-06-05 12:54:01 -0700 | [diff] [blame] | 25 | // Minimum number of JIT samples during launch to mark a method as hot in the profile. |
| 26 | static constexpr uint32_t kHotStartupMethodSamples = 1; |
Mathieu Chartier | 273d110 | 2017-06-06 17:07:13 -0700 | [diff] [blame^] | 27 | static constexpr uint32_t kHotStartupMethodSamplesLowRam = 256; |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 28 | 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 Chartier | 273d110 | 2017-06-06 17:07:13 -0700 | [diff] [blame^] | 32 | static constexpr uint32_t kHotStartupMethodSamplesNotSet = std::numeric_limits<uint32_t>::max(); |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 33 | |
| 34 | ProfileSaverOptions() : |
| 35 | enabled_(false), |
| 36 | min_save_period_ms_(kMinSavePeriodMs), |
| 37 | save_resolved_classes_delay_ms_(kSaveResolvedClassesDelayMs), |
Mathieu Chartier | 273d110 | 2017-06-06 17:07:13 -0700 | [diff] [blame^] | 38 | hot_startup_method_samples_(kHotStartupMethodSamplesNotSet), |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 39 | min_methods_to_save_(kMinMethodsToSave), |
| 40 | min_classes_to_save_(kMinClassesToSave), |
| 41 | min_notification_before_wake_(kMinNotificationBeforeWake), |
Calin Juravle | 9545f6d | 2017-03-16 19:05:09 -0700 | [diff] [blame] | 42 | max_notification_before_wake_(kMaxNotificationBeforeWake), |
| 43 | profile_path_("") {} |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 44 | |
| 45 | ProfileSaverOptions( |
| 46 | bool enabled, |
| 47 | uint32_t min_save_period_ms, |
| 48 | uint32_t save_resolved_classes_delay_ms, |
Mathieu Chartier | 7b135c8 | 2017-06-05 12:54:01 -0700 | [diff] [blame] | 49 | uint32_t hot_startup_method_samples, |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 50 | uint32_t min_methods_to_save, |
| 51 | uint32_t min_classes_to_save, |
| 52 | uint32_t min_notification_before_wake, |
Calin Juravle | 9545f6d | 2017-03-16 19:05:09 -0700 | [diff] [blame] | 53 | uint32_t max_notification_before_wake, |
| 54 | const std::string& profile_path): |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 55 | enabled_(enabled), |
| 56 | min_save_period_ms_(min_save_period_ms), |
| 57 | save_resolved_classes_delay_ms_(save_resolved_classes_delay_ms), |
Mathieu Chartier | 7b135c8 | 2017-06-05 12:54:01 -0700 | [diff] [blame] | 58 | hot_startup_method_samples_(hot_startup_method_samples), |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 59 | min_methods_to_save_(min_methods_to_save), |
| 60 | min_classes_to_save_(min_classes_to_save), |
| 61 | min_notification_before_wake_(min_notification_before_wake), |
Calin Juravle | 9545f6d | 2017-03-16 19:05:09 -0700 | [diff] [blame] | 62 | max_notification_before_wake_(max_notification_before_wake), |
| 63 | profile_path_(profile_path) {} |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 64 | |
| 65 | bool IsEnabled() const { |
| 66 | return enabled_; |
| 67 | } |
| 68 | void SetEnabled(bool enabled) { |
| 69 | enabled_ = enabled; |
| 70 | } |
| 71 | |
| 72 | uint32_t GetMinSavePeriodMs() const { |
| 73 | return min_save_period_ms_; |
| 74 | } |
| 75 | uint32_t GetSaveResolvedClassesDelayMs() const { |
| 76 | return save_resolved_classes_delay_ms_; |
| 77 | } |
Mathieu Chartier | 273d110 | 2017-06-06 17:07:13 -0700 | [diff] [blame^] | 78 | uint32_t GetHotStartupMethodSamples(bool is_low_ram) const { |
| 79 | uint32_t ret = hot_startup_method_samples_; |
| 80 | if (ret == kHotStartupMethodSamplesNotSet) { |
| 81 | ret = is_low_ram ? kHotStartupMethodSamplesLowRam : kHotStartupMethodSamples; |
| 82 | } |
| 83 | return ret; |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 84 | } |
| 85 | uint32_t GetMinMethodsToSave() const { |
| 86 | return min_methods_to_save_; |
| 87 | } |
| 88 | uint32_t GetMinClassesToSave() const { |
| 89 | return min_classes_to_save_; |
| 90 | } |
| 91 | uint32_t GetMinNotificationBeforeWake() const { |
| 92 | return min_notification_before_wake_; |
| 93 | } |
| 94 | uint32_t GetMaxNotificationBeforeWake() const { |
| 95 | return max_notification_before_wake_; |
| 96 | } |
Calin Juravle | 9545f6d | 2017-03-16 19:05:09 -0700 | [diff] [blame] | 97 | std::string GetProfilePath() const { |
| 98 | return profile_path_; |
| 99 | } |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 100 | |
| 101 | friend std::ostream & operator<<(std::ostream &os, const ProfileSaverOptions& pso) { |
| 102 | os << "enabled_" << pso.enabled_ |
| 103 | << ", min_save_period_ms_" << pso.min_save_period_ms_ |
| 104 | << ", save_resolved_classes_delay_ms_" << pso.save_resolved_classes_delay_ms_ |
Mathieu Chartier | 7b135c8 | 2017-06-05 12:54:01 -0700 | [diff] [blame] | 105 | << ", hot_startup_method_samples_" << pso.hot_startup_method_samples_ |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 106 | << ", min_methods_to_save_" << pso.min_methods_to_save_ |
| 107 | << ", min_classes_to_save_" << pso.min_classes_to_save_ |
| 108 | << ", min_notification_before_wake_" << pso.min_notification_before_wake_ |
| 109 | << ", max_notification_before_wake_" << pso.max_notification_before_wake_; |
| 110 | return os; |
| 111 | } |
| 112 | |
| 113 | bool enabled_; |
| 114 | uint32_t min_save_period_ms_; |
| 115 | uint32_t save_resolved_classes_delay_ms_; |
Mathieu Chartier | 273d110 | 2017-06-06 17:07:13 -0700 | [diff] [blame^] | 116 | // Do not access hot_startup_method_samples_ directly for reading since it may be set to the |
| 117 | // placeholder default. |
Mathieu Chartier | 7b135c8 | 2017-06-05 12:54:01 -0700 | [diff] [blame] | 118 | uint32_t hot_startup_method_samples_; |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 119 | uint32_t min_methods_to_save_; |
| 120 | uint32_t min_classes_to_save_; |
| 121 | uint32_t min_notification_before_wake_; |
| 122 | uint32_t max_notification_before_wake_; |
Calin Juravle | 9545f6d | 2017-03-16 19:05:09 -0700 | [diff] [blame] | 123 | std::string profile_path_; |
Calin Juravle | 138dbff | 2016-06-28 19:36:58 +0100 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | } // namespace art |
| 127 | |
| 128 | #endif // ART_RUNTIME_JIT_PROFILE_SAVER_OPTIONS_H_ |