Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Side by Side Diff: chrome/app/client_util.cc

Issue 7508034: Make a pre-read A/B field-trial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 key.ReadValueDW(L"PreRead", &pre_read);
135 key.Close(); 139 key.Close();
136 } 140 }
141
142 // The Syzygy project is a competing optimization technique. Part of the
143 // evaluation consists of an A/B experiment on Canary. As a baseline, we
144 // wish to evaluate startup time with preread enabled and disabled. We
145 // can't use base::FieldTrial as this only exists *after* chrome.dll is
146 // loaded. We override the registry setting with a coin-toss for the
147 // duration of this experiment.
148 pre_read = base::RandInt(0, 1);
149 DCHECK(pre_read == 0 || pre_read == 1);
150
151 // We communicate the coin-toss result via a side-channel
Sigurður Ásgeirsson 2011/08/04 15:32:00 This LGTM, except that we probably ought to file a
chrisha 2011/08/04 18:50:33 I added a comment to that effect here.
152 // (environment variable) to chrome.dll. This ensures that chrome.dll
153 // only reports experiment results if it has been launched by a
154 // chrome.exe that is actually running the experiment.
155 scoped_ptr<base::Environment> env(base::Environment::Create());
156 DCHECK(env.get() != NULL);
157 env->SetVar("CHROME_PRE_READ_EXPERIMENT",
158 pre_read ? "1" : "0");
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
145 168
146 return ::LoadLibraryExW(dir->c_str(), NULL, 169 return ::LoadLibraryExW(dir->c_str(), NULL,
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698