diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-03 06:14:45 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-03 06:14:45 +0000 |
commit | 85286b53fce1ded5c4ad5a9aaea6b1a7c2e7a2b1 (patch) | |
tree | b9507924c0cd2c70890289357a427e5dd69f979f /base/file_util_win.cc | |
parent | d27893f65dbd01a0d88dcda2a69f518e4b8a636d (diff) | |
download | chromium_src-85286b53fce1ded5c4ad5a9aaea6b1a7c2e7a2b1.zip chromium_src-85286b53fce1ded5c4ad5a9aaea6b1a7c2e7a2b1.tar.gz chromium_src-85286b53fce1ded5c4ad5a9aaea6b1a7c2e7a2b1.tar.bz2 |
Changing the pre-reading of chrome.dll to read it as an image section instead. XP ignores pages read as data
while mapping image sections. This shows a reasonable improvement in cold startup performance on XP.
This change only comes into effect for headless mode which enables us to try out the effect on the perf bots
and for chrome frame processes.
Code mostly written by Amit.
Added a chrome frame perf tests which measures LoadLibrary in cold mode with pre-reading.
Bug=45510
Review URL: http://codereview.chromium.org/2805064
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51594 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_win.cc')
-rw-r--r-- | base/file_util_win.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/base/file_util_win.cc b/base/file_util_win.cc index 74b9406..26955f2 100644 --- a/base/file_util_win.cc +++ b/base/file_util_win.cc @@ -14,6 +14,7 @@ #include "base/file_path.h" #include "base/logging.h" +#include "base/pe_image.h" #include "base/scoped_comptr_win.h" #include "base/scoped_handle.h" #include "base/string_util.h" @@ -1100,4 +1101,28 @@ bool NormalizeFilePath(const FilePath& path, FilePath* real_path) { return success; } +bool PreReadImage(const wchar_t* file_path, size_t size_to_read, + size_t step_size) { + HMODULE dll_module = LoadLibraryExW( + file_path, + NULL, + LOAD_WITH_ALTERED_SEARCH_PATH | DONT_RESOLVE_DLL_REFERENCES); + + if (!dll_module) + return false; + + PEImage pe_image(dll_module); + PIMAGE_NT_HEADERS nt_headers = pe_image.GetNTHeaders(); + size_t actual_size_to_read = size_to_read ? size_to_read : + nt_headers->OptionalHeader.SizeOfImage; + volatile uint8* touch = reinterpret_cast<uint8*>(dll_module); + size_t offset = 0; + while (offset < actual_size_to_read) { + uint8 unused = *(touch + offset); + offset += step_size; + } + FreeLibrary(dll_module); + return true; +} + } // namespace file_util |