diff options
| author | 2017-08-28 09:52:55 -0700 | |
|---|---|---|
| committer | 2017-08-29 13:17:09 -0700 | |
| commit | 150d25df5d75d55735b0ec49305784e5dc83cce6 (patch) | |
| tree | 2eb311a83cb101620c0acc08901e114d8a5835e3 | |
| parent | 8920835161a359ce45250d04890bb054a3832977 (diff) | |
Enable dex madvise hints for low ram devices
Enable layout based madvise hints for low ram devices.
Reduces flash reads by 40% for AUPT use cases on low ram devices.
Test: build and flash
Bug: 63178181
(cherry picked from commit 63199d75a146cbcac1cbcac944cf054524ca8848)
Change-Id: Ica0abc10b8356fbd7ab38a71df91c2da74bf505b
| -rw-r--r-- | runtime/oat_file.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc index 2d8d6ba147..d9cfa533ca 100644 --- a/runtime/oat_file.cc +++ b/runtime/oat_file.cc @@ -75,7 +75,7 @@ static constexpr bool kUseDlopenOnHost = true; static constexpr bool kPrintDlOpenErrorMessage = false; // If true, we advise the kernel about dex file mem map accesses. -static constexpr bool kMadviseDexFileAccesses = false; +static constexpr bool kMadviseDexFileAccesses = true; // Note for OatFileBase and descendents: // @@ -1498,11 +1498,13 @@ const DexFile::ClassDef* OatFile::OatDexFile::FindClassDef(const DexFile& dex_fi // Madvise the dex file based on the state we are moving to. void OatDexFile::MadviseDexFile(const DexFile& dex_file, MadviseState state) { - if (!kMadviseDexFileAccesses) { + const bool low_ram = Runtime::Current()->GetHeap()->IsLowMemoryMode(); + // TODO: Also do madvise hints for non low ram devices. + if (!kMadviseDexFileAccesses || !low_ram) { return; } if (state == MadviseState::kMadviseStateAtLoad) { - if (Runtime::Current()->GetHeap()->IsLowMemoryMode()) { + if (low_ram) { // 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. |