Only MADV_RANDOM for low RAM devices
Added logic to do MADV_RANDOM only for low ram devices since this
hurts performance on high end devices.
Test: build and flash
Bug: 63178181
Change-Id: Ic1b21035b6cb8e3117b910d2e53d27405310116b
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 0d04368..9e95ff3 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -1502,10 +1502,14 @@
return;
}
if (state == MadviseState::kMadviseStateAtLoad) {
- // Default every dex file to MADV_RANDOM when its loaded by default.
- MadviseLargestPageAlignedRegion(dex_file.Begin(),
- dex_file.Begin() + dex_file.Size(),
- MADV_RANDOM);
+ if (Runtime::Current()->GetHeap()->IsLowMemoryMode()) {
+ // Default every dex file to MADV_RANDOM when its loaded by default for low ram devices.
+ // Other devices have enough page cache to get performance benefits from loading more pages
+ // into the page cache.
+ MadviseLargestPageAlignedRegion(dex_file.Begin(),
+ dex_file.Begin() + dex_file.Size(),
+ MADV_RANDOM);
+ }
}
const OatFile::OatDexFile* oat_dex_file = dex_file.GetOatDexFile();
if (oat_dex_file != nullptr) {