summaryrefslogtreecommitdiff
path: root/runtime/jit/profile_saver.cc
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2024-05-28 15:10:32 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2024-06-03 13:17:38 +0000
commit85ee2c92239fbafc22c2c47b22faa817a0a4b034 (patch)
treebc40d4315d65bbfae6b87ff264098e55130af667 /runtime/jit/profile_saver.cc
parent952b187935a922acf4ad5d70e76ab34dc94b193c (diff)
Rewrite how we identify hot methods.
Use the kAccPreviouslyWarm as soon as a method gets scheduled for JITting. The profile saver now only uses that flag. For benefiting simplicity, deprecate the -Xps-hot-startup-method-samples flag (unused in the code base). Test: second run after speed-profile contains less JITting Bug: 333614471 Bug: 333701031 Change-Id: I2b846026f7d74d20ea761421b857db3834b3011c
Diffstat (limited to 'runtime/jit/profile_saver.cc')
-rw-r--r--runtime/jit/profile_saver.cc32
1 files changed, 4 insertions, 28 deletions
diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc
index abf01f5498..3506faaa7f 100644
--- a/runtime/jit/profile_saver.cc
+++ b/runtime/jit/profile_saver.cc
@@ -335,7 +335,6 @@ class ProfileSaver::GetClassesAndMethodsHelper {
REQUIRES_SHARED(Locks::mutator_lock_)
: startup_(startup),
profile_boot_class_path_(options.GetProfileBootClassPath()),
- hot_method_sample_threshold_(CalculateHotMethodSampleThreshold(startup, options)),
extra_flags_(GetExtraMethodHotnessFlags(options)),
annotation_(annotation),
arena_stack_(Runtime::Current()->GetArenaPool()),
@@ -358,10 +357,6 @@ class ProfileSaver::GetClassesAndMethodsHelper {
void CollectClasses(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
void UpdateProfile(const std::set<std::string>& locations, ProfileCompilationInfo* profile_info);
- uint32_t GetHotMethodSampleThreshold() const {
- return hot_method_sample_threshold_;
- }
-
size_t GetNumberOfHotMethods() const {
return number_of_hot_methods_;
}
@@ -409,19 +404,6 @@ class ProfileSaver::GetClassesAndMethodsHelper {
using DexFileRecordsMap = ScopedArenaHashMap<const DexFile*, DexFileRecords*>;
- static uint32_t CalculateHotMethodSampleThreshold(bool startup,
- const ProfileSaverOptions& options) {
- Runtime* runtime = Runtime::Current();
- if (startup) {
- const bool is_low_ram = runtime->GetHeap()->IsLowMemoryMode();
- return options.GetHotStartupMethodSamples(is_low_ram);
- } else if (runtime->GetJit() != nullptr) {
- return runtime->GetJit()->WarmMethodThreshold();
- } else {
- return std::numeric_limits<uint32_t>::max();
- }
- }
-
ALWAYS_INLINE static bool ShouldCollectClasses(bool startup) {
// We only record classes for the startup case. This may change in the future.
return startup;
@@ -434,7 +416,6 @@ class ProfileSaver::GetClassesAndMethodsHelper {
const bool startup_;
const bool profile_boot_class_path_;
- const uint32_t hot_method_sample_threshold_;
const uint32_t extra_flags_;
const ProfileCompilationInfo::ProfileSampleAnnotation annotation_;
ArenaStack arena_stack_;
@@ -609,7 +590,6 @@ void ProfileSaver::GetClassesAndMethodsHelper::UpdateProfile(const std::set<std:
ProfileCompilationInfo* profile_info) {
// Move members to local variables to allow the compiler to optimize this properly.
const bool startup = startup_;
- const uint32_t hot_method_sample_threshold = hot_method_sample_threshold_;
const uint32_t base_flags =
(startup ? Hotness::kFlagStartup : Hotness::kFlagPostStartup) | extra_flags_;
@@ -619,10 +599,9 @@ void ProfileSaver::GetClassesAndMethodsHelper::UpdateProfile(const std::set<std:
uint16_t initial_value = Runtime::Current()->GetJITOptions()->GetWarmupThreshold();
auto get_method_flags = [&](ArtMethod& method) {
- // Mark methods as hot if they have more than hot_method_sample_threshold
- // samples. This means they will get compiled by the compiler driver.
- if (method.PreviouslyWarm() ||
- method.CounterHasReached(hot_method_sample_threshold, initial_value)) {
+ // Mark methods as hot if they are marked as such (warm for the runtime
+ // means hot for the profile).
+ if (method.PreviouslyWarm()) {
++number_of_hot_methods;
return enum_cast<ProfileCompilationInfo::MethodHotness::Flag>(base_flags | Hotness::kFlagHot);
} else if (method.CounterHasChanged(initial_value)) {
@@ -750,7 +729,6 @@ void ProfileSaver::FetchAndCacheResolvedClassesAndMethods(bool startup) {
profiler_pthread = profiler_pthread_;
}
- uint32_t hot_method_sample_threshold = 0u;
size_t number_of_hot_methods = 0u;
size_t number_of_sampled_methods = 0u;
{
@@ -765,7 +743,6 @@ void ProfileSaver::FetchAndCacheResolvedClassesAndMethods(bool startup) {
ScopedObjectAccess soa(self);
GetClassesAndMethodsHelper helper(startup, options_, GetProfileSampleAnnotation());
- hot_method_sample_threshold = helper.GetHotMethodSampleThreshold();
helper.CollectClasses(self);
// Release the mutator lock. We shall need to re-acquire the lock for a moment to
@@ -800,8 +777,7 @@ void ProfileSaver::FetchAndCacheResolvedClassesAndMethods(bool startup) {
}
VLOG(profiler) << "Profile saver recorded " << number_of_hot_methods
<< " hot methods and " << number_of_sampled_methods
- << " sampled methods with threshold " << hot_method_sample_threshold
- << " in " << PrettyDuration(NanoTime() - start_time);
+ << " sampled methods in " << PrettyDuration(NanoTime() - start_time);
}
bool ProfileSaver::ProcessProfilingInfo(