OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <windows.h> | 5 #include <windows.h> |
6 #include <shlwapi.h> | 6 #include <shlwapi.h> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/win/registry.h" | 14 #include "base/rand_util.h" // For PreReadExperiment field-trial. |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "base/version.h" | 17 #include "base/version.h" |
18 #include "base/win/registry.h" | |
18 #include "chrome/app/breakpad_win.h" | 19 #include "chrome/app/breakpad_win.h" |
19 #include "chrome/app/client_util.h" | 20 #include "chrome/app/client_util.h" |
20 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_result_codes.h" | 22 #include "chrome/common/chrome_result_codes.h" |
22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/installer/util/browser_distribution.h" | 24 #include "chrome/installer/util/browser_distribution.h" |
24 #include "chrome/installer/util/channel_info.h" | 25 #include "chrome/installer/util/channel_info.h" |
25 #include "chrome/installer/util/install_util.h" | 26 #include "chrome/installer/util/install_util.h" |
26 #include "chrome/installer/util/google_update_constants.h" | 27 #include "chrome/installer/util/google_update_constants.h" |
27 #include "chrome/installer/util/google_update_settings.h" | 28 #include "chrome/installer/util/google_update_settings.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
119 // for other sections. We can skip over these pages to avoid a soft page | 120 // for other sections. We can skip over these pages to avoid a soft page |
120 // fault which may not occur during code execution. However skipping 4K at | 121 // fault which may not occur during code execution. However skipping 4K at |
121 // a time still has better performance over 32K and 16K according to data. | 122 // a time still has better performance over 32K and 16K according to data. |
122 // TODO(ananta): Investigate this and tune. | 123 // TODO(ananta): Investigate this and tune. |
123 const size_t kStepSize = 4 * 1024; | 124 const size_t kStepSize = 4 * 1024; |
124 | 125 |
125 DWORD pre_read_size = 0; | 126 DWORD pre_read_size = 0; |
126 DWORD pre_read_step_size = kStepSize; | 127 DWORD pre_read_step_size = kStepSize; |
127 DWORD pre_read = 1; | 128 DWORD pre_read = 1; |
128 | 129 |
130 // TODO(chrisha): This path should not be ChromeFrame specific, and it | |
131 // should not be hard-coded with 'Google' in the path. Rather, it should | |
132 // use the product name. | |
129 base::win::RegKey key(HKEY_CURRENT_USER, L"Software\\Google\\ChromeFrame", | 133 base::win::RegKey key(HKEY_CURRENT_USER, L"Software\\Google\\ChromeFrame", |
130 KEY_QUERY_VALUE); | 134 KEY_QUERY_VALUE); |
131 if (key.Valid()) { | 135 if (key.Valid()) { |
132 key.ReadValueDW(L"PreReadSize", &pre_read_size); | 136 key.ReadValueDW(L"PreReadSize", &pre_read_size); |
133 key.ReadValueDW(L"PreReadStepSize", &pre_read_step_size); | 137 key.ReadValueDW(L"PreReadStepSize", &pre_read_step_size); |
134 key.ReadValueDW(L"PreRead", &pre_read); | 138 // Use 'PreReadExperiment' rather than 'PreRead' for now. |
139 // key.ReadValueDW(L"PreRead", &pre_read); | |
140 | |
141 // The Syzygy project is a competing optimization technique. Part of the | |
142 // evaluation consists of an A/B experiment on Canary. As a baseline, we | |
143 // wish to evaluate startup time with preread enabled and disabled. We | |
144 // can't use base::FieldTrial as this only exists *after* chrome.dll is | |
145 // loaded, thus we store the result of our coin-toss in the registry. We | |
146 // do this using a separate registry key so that we can revert to the | |
147 // old behaviour after the experiment. | |
148 const wchar_t kPreReadExperimentKey[] = L"PreReadExperiment"; | |
Sigurður Ásgeirsson
2011/08/04 13:35:32
nit: static
chrisha
2011/08/04 14:48:40
Done.
| |
149 // Try to look up the earlier result. | |
150 if (key.ReadValueDW(kPreReadExperimentKey, &pre_read) != 0) { | |
151 // If this fails, toss a coin and save the result. The coin-toss is only | |
152 // used if it has been successfully written. | |
153 DWORD coin_toss = base::RandInt(0, 1); | |
154 if (key.WriteValue(kPreReadExperimentKey, coin_toss) == 0) | |
jar (doing other things)
2011/08/03 21:24:34
It is undesirable to save a random number into the
Sigurður Ásgeirsson
2011/08/04 13:35:32
The range of the coin_toss here is 0 to 1. It woul
chrisha
2011/08/04 14:48:40
Done.
jar (doing other things)
2011/08/04 18:34:28
My apologies for my mis-read. Thanks for the asse
| |
155 pre_read = coin_toss; | |
156 } | |
157 | |
135 key.Close(); | 158 key.Close(); |
136 } | 159 } |
137 if (pre_read) { | 160 if (pre_read) { |
138 TRACE_EVENT_BEGIN_ETW("PreReadImage", 0, ""); | 161 TRACE_EVENT_BEGIN_ETW("PreReadImage", 0, ""); |
139 file_util::PreReadImage(dir->c_str(), pre_read_size, pre_read_step_size); | 162 file_util::PreReadImage(dir->c_str(), pre_read_size, pre_read_step_size); |
140 TRACE_EVENT_END_ETW("PreReadImage", 0, ""); | 163 TRACE_EVENT_END_ETW("PreReadImage", 0, ""); |
141 } | 164 } |
142 } | 165 } |
143 #endif // NDEBUG | 166 #endif // NDEBUG |
144 #endif // WIN_DISABLE_PREREAD | 167 #endif // WIN_DISABLE_PREREAD |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
309 } | 332 } |
310 }; | 333 }; |
311 | 334 |
312 MainDllLoader* MakeMainDllLoader() { | 335 MainDllLoader* MakeMainDllLoader() { |
313 #if defined(GOOGLE_CHROME_BUILD) | 336 #if defined(GOOGLE_CHROME_BUILD) |
314 return new ChromeDllLoader(); | 337 return new ChromeDllLoader(); |
315 #else | 338 #else |
316 return new ChromiumDllLoader(); | 339 return new ChromiumDllLoader(); |
317 #endif | 340 #endif |
318 } | 341 } |
OLD | NEW |