Skip to content

Commit

Permalink
Remove code related to the OnlyIfCold option of the PreRead field trial.
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
fdoray authored and Commit bot committed Feb 3, 2016
1 parent 89ad105 commit d926fee
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 49 deletions.
1 change: 0 additions & 1 deletion chrome/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,6 @@ if (is_win) {
]
deps = [
"//base",
"//components/startup_metric_utils/browser:lib",
]
}
}
Expand Down
26 changes: 0 additions & 26 deletions chrome/app/file_pre_reader_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
#include <windows.h>
#include <stdint.h>

#include "base/debug/alias.h"
#include "base/files/file.h"
#include "base/files/memory_mapped_file.h"
#include "base/logging.h"
#include "base/scoped_native_library.h"
#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 {

Expand Down Expand Up @@ -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();
Expand Down
5 changes: 0 additions & 5 deletions chrome/app/file_pre_reader_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 1 addition & 11 deletions chrome/app/main_dll_loader_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion chrome/chrome_exe.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,6 @@
],
'dependencies': [
'../base/base.gyp:base',
'../components/components.gyp:startup_metric_utils_browser',
],
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit d926fee

Please sign in to comment.