diff options
-rw-r--r-- | runtime/runtime.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/runtime/runtime.cc b/runtime/runtime.cc index ebad371d17..280fd511d9 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -3372,6 +3372,14 @@ void Runtime::MadviseFileForRange(size_t madvise_size_limit_bytes, const uint8_t* map_begin, const uint8_t* map_end, const std::string& file_name) { + // Short-circuit the madvise optimization for background processes. This + // avoids IO and memory contention with foreground processes, particularly + // those involving app startup. + const Runtime* runtime = Runtime::Current(); + if (runtime != nullptr && !runtime->InJankPerceptibleProcessState()) { + return; + } + // Ideal blockTransferSize for madvising files (128KiB) static constexpr size_t kIdealIoTransferSizeBytes = 128*1024; |