Add madvising of .odex, .vdex and .art files
1. When mmaping {.art, .odex, .vdex} files madvise them to MADV_WILLNEED
2. Add system properties to limit the madvise size/range
Test: presubmit
Bug: 178853586
Change-Id: I14afc7cc038ebbf6bba5a393ef222050284dd86d
diff --git a/runtime/runtime.h b/runtime/runtime.h
index c9142f6..43a8454 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -885,6 +885,18 @@
return madvise_random_access_;
}
+ size_t GetMadviseWillNeedSizeVdex() const {
+ return madvise_willneed_vdex_filesize_;
+ }
+
+ size_t GetMadviseWillNeedSizeOdex() const {
+ return madvise_willneed_odex_filesize_;
+ }
+
+ size_t GetMadviseWillNeedSizeArt() const {
+ return madvise_willneed_art_filesize_;
+ }
+
const std::string& GetJdwpOptions() {
return jdwp_options_;
}
@@ -969,6 +981,12 @@
void RequestMetricsReport(bool synchronous = true);
+ static void MadviseFileForRange(size_t madvise_size_limit_bytes,
+ size_t map_size_bytes,
+ const uint8_t* map_begin,
+ const uint8_t* map_end,
+ const std::string& file_name);
+
private:
static void InitPlatformSignalHandlers();
@@ -1232,6 +1250,18 @@
// This is beneficial for low RAM devices since it reduces page cache thrashing.
bool madvise_random_access_;
+ // Limiting size (in bytes) for applying MADV_WILLNEED on vdex files
+ // A 0 for this will turn off madvising to MADV_WILLNEED
+ size_t madvise_willneed_vdex_filesize_;
+
+ // Limiting size (in bytes) for applying MADV_WILLNEED on odex files
+ // A 0 for this will turn off madvising to MADV_WILLNEED
+ size_t madvise_willneed_odex_filesize_;
+
+ // Limiting size (in bytes) for applying MADV_WILLNEED on art files
+ // A 0 for this will turn off madvising to MADV_WILLNEED
+ size_t madvise_willneed_art_filesize_;
+
// Whether the application should run in safe mode, that is, interpreter only.
bool safe_mode_;