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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | chrome/browser/browser_main_win.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/app/client_util.cc
===================================================================
--- chrome/app/client_util.cc (revision 95298)
+++ chrome/app/client_util.cc (working copy)
@@ -11,10 +11,11 @@
#include "base/file_util.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
-#include "base/win/registry.h"
+#include "base/rand_util.h" // For PreReadExperiment field-trial.
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/version.h"
+#include "base/win/registry.h"
#include "chrome/app/breakpad_win.h"
#include "chrome/app/client_util.h"
#include "chrome/common/chrome_constants.h"
@@ -126,12 +127,47 @@
DWORD pre_read_step_size = kStepSize;
DWORD pre_read = 1;
+ // TODO(chrisha): This path should not be ChromeFrame specific, and it
+ // should not be hard-coded with 'Google' in the path. Rather, it should
+ // use the product name.
base::win::RegKey key(HKEY_CURRENT_USER, L"Software\\Google\\ChromeFrame",
KEY_QUERY_VALUE);
if (key.Valid()) {
key.ReadValueDW(L"PreReadSize", &pre_read_size);
key.ReadValueDW(L"PreReadStepSize", &pre_read_step_size);
- key.ReadValueDW(L"PreRead", &pre_read);
+ // Use 'PreReadExperiment' rather than 'PreRead' for now.
+ // key.ReadValueDW(L"PreRead", &pre_read);
+
+ // The Syzygy project is a competing optimization technique. Part of the
+ // evaluation consists of an A/B experiment on Canary. As a baseline, we
+ // wish to evaluate startup time with preread enabled and disabled. We
+ // can't use base::FieldTrial as this only exists *after* chrome.dll is
+ // loaded, thus we store the result of our coin-toss in the registry. We
+ // do this using a separate registry key so that we can revert to the
+ // old behaviour after the experiment.
+ static const wchar_t kPreReadExperimentKey[] = L"PreReadExperiment";
+ // Try to look up the earlier result.
+ if (key.ReadValueDW(kPreReadExperimentKey, &pre_read) != S_OK) {
+ // If this fails, toss a coin and save the result. The coin-toss is only
+ // used if it has been successfully written. We assert that the coin-
+ // toss produces a value of 0 or 1. While this amounts to storing a
+ // random number in the registry, it's range is too small to be used
+ // for any kind of user tracking.
+ DWORD coin_toss = base::RandInt(0, 1);
+ DCHECK(coin_toss == 0 || coin_toss == 1);
+ if (key.WriteValue(kPreReadExperimentKey, coin_toss) == S_OK)
+ pre_read = coin_toss;
+ }
+
+ // We communicate the coin-toss result via a side-channel
+ // (environment variable) to chrome.dll. This ensures that chrome.dll
+ // only reports experiment results if it has been launched by a
+ // chrome.exe that is actually running the experiment.
+ scoped_ptr<base::Environment> env(base::Environment::Create());
+ DCHECK(env.get() != NULL);
+ env->SetVar("CHROME_PRE_READ_EXPERIMENT",
Sigurður Ásgeirsson 2011/08/04 15:18:38 as we discussed, this only runs if the regkey exis
chrisha 2011/08/04 15:26:50 Done.
+ pre_read ? "1" : "0");
+
key.Close();
}
if (pre_read) {
« no previous file with comments | « no previous file | chrome/browser/browser_main.cc » ('j') | chrome/browser/browser_main_win.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698