From d926feefbcaf1fb6126caeaa811c5e47339d4b31 Mon Sep 17 00:00:00 2001 From: fdoray Date: Wed, 3 Feb 2016 11:28:23 -0800 Subject: [PATCH] Remove code related to the OnlyIfCold option of the PreRead field trial. Experimental results show that the heuristic that was used to determine whether a binary is warm isn't good enough. BUG=547794 Review URL: https://codereview.chromium.org/1654823004 Cr-Commit-Position: refs/heads/master@{#373301} --- chrome/BUILD.gn | 1 - chrome/app/file_pre_reader_win.cc | 26 ------------------- chrome/app/file_pre_reader_win.h | 5 ---- chrome/app/main_dll_loader_win.cc | 12 +-------- chrome/chrome_exe.gypi | 1 - .../common/pre_read_field_trial_utils_win.cc | 2 -- .../common/pre_read_field_trial_utils_win.h | 3 --- 7 files changed, 1 insertion(+), 49 deletions(-) diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn index 2d5ba6dac0a454..b6178eec46231c 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn @@ -534,7 +534,6 @@ if (is_win) { ] deps = [ "//base", - "//components/startup_metric_utils/browser:lib", ] } } diff --git a/chrome/app/file_pre_reader_win.cc b/chrome/app/file_pre_reader_win.cc index 60626128129c1f..7d5724476b9aee 100644 --- a/chrome/app/file_pre_reader_win.cc +++ b/chrome/app/file_pre_reader_win.cc @@ -7,7 +7,6 @@ #include #include -#include "base/debug/alias.h" #include "base/files/file.h" #include "base/files/memory_mapped_file.h" #include "base/logging.h" @@ -15,7 +14,6 @@ #include "base/threading/thread_restrictions.h" #include "base/win/pe_image.h" #include "base/win/windows_version.h" -#include "components/startup_metric_utils/browser/startup_metric_utils.h" namespace { @@ -104,30 +102,6 @@ void PreReadFile(const base::FilePath& file_path) { } } -bool IsMemoryMappedFileWarm(const base::MemoryMappedFile& memory_mapped_file) { - base::ThreadRestrictions::AssertIOAllowed(); - if (!memory_mapped_file.IsValid()) - return false; - - uint32_t initial_hard_fault_count = 0; - if (!startup_metric_utils::GetHardFaultCountForCurrentProcess( - &initial_hard_fault_count)) - return false; - - // Read a byte from the first page of the memory map. - const uint8_t dummy = *(memory_mapped_file.data()); - base::debug::Alias(&dummy); - - uint32_t final_hard_fault_count = 0; - if (!startup_metric_utils::GetHardFaultCountForCurrentProcess( - &final_hard_fault_count)) - return false; - - // Return true if reading a byte from the first page of the memory map - // generated a hard fault. - return initial_hard_fault_count == final_hard_fault_count; -} - void PreReadMemoryMappedFile(const base::MemoryMappedFile& memory_mapped_file, const base::FilePath& file_path) { base::ThreadRestrictions::AssertIOAllowed(); diff --git a/chrome/app/file_pre_reader_win.h b/chrome/app/file_pre_reader_win.h index d2f75f76550cd8..da88ba41242e98 100644 --- a/chrome/app/file_pre_reader_win.h +++ b/chrome/app/file_pre_reader_win.h @@ -19,11 +19,6 @@ class MemoryMappedFile; // pre-reading non-PE files is not supported. void PreReadFile(const base::FilePath& file_path); -// Returns true if the first page of |memory_mapped_file| is warm. This function -// must be called from a single-threaded process because it relies on the -// process-wide hard fault counter. Returns false on failure. -bool IsMemoryMappedFileWarm(const base::MemoryMappedFile& memory_mapped_file); - // Reads |memory_mapped_file| to avoid touching the disk when the mapped file is // actually used. The function checks the Windows version to determine which // pre-reading mechanism to use. On Win8+, it uses ::PrefetchVirtualMemory. On diff --git a/chrome/app/main_dll_loader_win.cc b/chrome/app/main_dll_loader_win.cc index 274da31f9e825c..4794fba522b78a 100644 --- a/chrome/app/main_dll_loader_win.cc +++ b/chrome/app/main_dll_loader_win.cc @@ -75,17 +75,7 @@ HMODULE LoadModuleWithDirectory(const base::FilePath& module) { base::ThreadPriority::DISPLAY); } - if (pre_read_options.only_if_cold) { - base::MemoryMappedFile module_memory_map; - const bool map_initialize_success = module_memory_map.Initialize(module); - DCHECK(map_initialize_success); - if (!IsMemoryMappedFileWarm(module_memory_map)) { - if (pre_read_options.prefetch_virtual_memory) - PreReadMemoryMappedFile(module_memory_map, module); - else - PreReadFile(module); - } - } else if (pre_read_options.prefetch_virtual_memory) { + if (pre_read_options.prefetch_virtual_memory) { base::MemoryMappedFile module_memory_map; const bool map_initialize_success = module_memory_map.Initialize(module); DCHECK(map_initialize_success); diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index 41150ff354485d..0a9514c3a2a395 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -513,7 +513,6 @@ ], 'dependencies': [ '../base/base.gyp:base', - '../components/components.gyp:startup_metric_utils_browser', ], }, ], diff --git a/components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc b/components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc index dbb32bfd718c36..229d40281be8b3 100644 --- a/components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc +++ b/components/startup_metric_utils/common/pre_read_field_trial_utils_win.cc @@ -31,7 +31,6 @@ const char kPreReadSyntheticFieldTrialName[] = "SyntheticPreRead"; // name. const base::char16 kNoPreReadVariationName[] = L"NoPreRead"; const base::char16 kHighPriorityVariationName[] = L"HighPriority"; -const base::char16 kOnlyIfColdVariationName[] = L"OnlyIfCold"; const base::char16 kPrefetchVirtualMemoryVariationName[] = L"PrefetchVirtualMemory"; const base::char16 kNoPrefetchArgumentVariationName[] = L"NoPrefetchArgument"; @@ -69,7 +68,6 @@ void InitializePreReadOptions(const base::string16& product_registry_path) { // Set the PreRead field trial's options. g_pre_read_options.pre_read = !ReadBool(key, kNoPreReadVariationName); g_pre_read_options.high_priority = ReadBool(key, kHighPriorityVariationName); - g_pre_read_options.only_if_cold = ReadBool(key, kOnlyIfColdVariationName); g_pre_read_options.prefetch_virtual_memory = ReadBool(key, kPrefetchVirtualMemoryVariationName); g_pre_read_options.use_prefetch_argument = diff --git a/components/startup_metric_utils/common/pre_read_field_trial_utils_win.h b/components/startup_metric_utils/common/pre_read_field_trial_utils_win.h index a2aaf4ae5e1b59..9bce57bcbf3d93 100644 --- a/components/startup_metric_utils/common/pre_read_field_trial_utils_win.h +++ b/components/startup_metric_utils/common/pre_read_field_trial_utils_win.h @@ -27,9 +27,6 @@ struct PreReadOptions { // Pre-read DLLs with a high thread priority. bool high_priority; - // Pre-read DLLs only when they are cold. - bool only_if_cold; - // Pre-read DLLs using the ::PrefetchVirtualMemory function, if available. bool prefetch_virtual_memory;