Update startup compilation thresholds
This change aims to compile less startup methods to save RAM and
reduce code size. Numbers are from shortly after launching the apps.
Leave cutoff as 1 for high end devices for now. We may want to
revisit that later.
For low ram devices, the cutoff is 256. This regresses startup time
by 1% but saves more RAM. Results:
(odex+vdex) PSS: -25% average
odex size: -42% average
vdex size unchanged
Apps: Gmail, Maps, YouTube, Search
Spreadsheet at go/compilethreshold
Bug: 36457259
Test: test-art-host
Change-Id: I49d157df9379532d8d7a1ea1d844bb4beb195bb2
diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc
index 68f33bd..edce9cd 100644
--- a/runtime/jit/profile_saver.cc
+++ b/runtime/jit/profile_saver.cc
@@ -251,7 +251,8 @@
MethodReferenceCollection hot_methods(allocator.Adapter(), allocator.Adapter());
MethodReferenceCollection startup_methods(allocator.Adapter(), allocator.Adapter());
TypeReferenceCollection resolved_classes(allocator.Adapter(), allocator.Adapter());
- const size_t hot_threshold = options_.GetHotStartupMethodSamples();
+ const bool is_low_ram = Runtime::Current()->GetHeap()->IsLowMemoryMode();
+ const size_t hot_threshold = options_.GetHotStartupMethodSamples(is_low_ram);
{
ScopedObjectAccess soa(self);
gc::ScopedGCCriticalSection sgcs(self,
diff --git a/runtime/jit/profile_saver_options.h b/runtime/jit/profile_saver_options.h
index 455bc1a..44550f4 100644
--- a/runtime/jit/profile_saver_options.h
+++ b/runtime/jit/profile_saver_options.h
@@ -24,16 +24,18 @@
static constexpr uint32_t kSaveResolvedClassesDelayMs = 5 * 1000; // 5 seconds
// Minimum number of JIT samples during launch to mark a method as hot in the profile.
static constexpr uint32_t kHotStartupMethodSamples = 1;
+ static constexpr uint32_t kHotStartupMethodSamplesLowRam = 256;
static constexpr uint32_t kMinMethodsToSave = 10;
static constexpr uint32_t kMinClassesToSave = 10;
static constexpr uint32_t kMinNotificationBeforeWake = 10;
static constexpr uint32_t kMaxNotificationBeforeWake = 50;
+ static constexpr uint32_t kHotStartupMethodSamplesNotSet = std::numeric_limits<uint32_t>::max();
ProfileSaverOptions() :
enabled_(false),
min_save_period_ms_(kMinSavePeriodMs),
save_resolved_classes_delay_ms_(kSaveResolvedClassesDelayMs),
- hot_startup_method_samples_(kHotStartupMethodSamples),
+ hot_startup_method_samples_(kHotStartupMethodSamplesNotSet),
min_methods_to_save_(kMinMethodsToSave),
min_classes_to_save_(kMinClassesToSave),
min_notification_before_wake_(kMinNotificationBeforeWake),
@@ -73,8 +75,12 @@
uint32_t GetSaveResolvedClassesDelayMs() const {
return save_resolved_classes_delay_ms_;
}
- uint32_t GetHotStartupMethodSamples() const {
- return hot_startup_method_samples_;
+ uint32_t GetHotStartupMethodSamples(bool is_low_ram) const {
+ uint32_t ret = hot_startup_method_samples_;
+ if (ret == kHotStartupMethodSamplesNotSet) {
+ ret = is_low_ram ? kHotStartupMethodSamplesLowRam : kHotStartupMethodSamples;
+ }
+ return ret;
}
uint32_t GetMinMethodsToSave() const {
return min_methods_to_save_;
@@ -107,6 +113,8 @@
bool enabled_;
uint32_t min_save_period_ms_;
uint32_t save_resolved_classes_delay_ms_;
+ // Do not access hot_startup_method_samples_ directly for reading since it may be set to the
+ // placeholder default.
uint32_t hot_startup_method_samples_;
uint32_t min_methods_to_save_;
uint32_t min_classes_to_save_;