diff options
author | semenzato@chromium.org <semenzato@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 04:40:11 +0000 |
---|---|---|
committer | semenzato@chromium.org <semenzato@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-09 04:40:11 +0000 |
commit | 490d446b454485c5005c3a5f226a39c41816257a (patch) | |
tree | 565efc142f8800925a39d9d89bcf6dd70a0fa415 | |
parent | 33b12f1babeba2db715f3c9f80111dc3fe355c40 (diff) | |
download | chromium_src-490d446b454485c5005c3a5f226a39c41816257a.zip chromium_src-490d446b454485c5005c3a5f226a39c41816257a.tar.gz chromium_src-490d446b454485c5005c3a5f226a39c41816257a.tar.bz2 |
Add zram field trial.
This adds a field trial for compressed swap. Chrome OS picks the trial
group to be used, based on the HW address of the wifi controller. Chrome
assigns a 100% probability to the group picked by Chrome OS.
BUG=chromium-os:37583
TEST=manually tested
Review URL: https://chromiumcodereview.appspot.com/11744024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175704 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/chrome_browser_main_chromeos.cc | 38 | ||||
-rw-r--r-- | chrome/browser/chromeos/chrome_browser_main_chromeos.h | 1 |
2 files changed, 39 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 5b947a9..cb8018c 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -12,6 +12,7 @@ #include "base/callback.h" #include "base/chromeos/chromeos_version.h" #include "base/command_line.h" +#include "base/file_util.h" #include "base/lazy_instance.h" #include "base/linux_util.h" #include "base/message_loop.h" @@ -717,6 +718,7 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { SetupLowMemoryHeadroomFieldTrial(); + SetupZramFieldTrial(); } void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { @@ -765,4 +767,40 @@ void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { } } + +void ChromeBrowserMainPartsChromeos::SetupZramFieldTrial() { + // The dice for this experiment have been thrown at boot. The selected group + // number is stored in a file. + const FilePath kZramGroupPath("/home/chronos/.swap_exp_enrolled"); + std::string zram_file_content; + // If the file does not exist, the experiment has not started. + if (!file_util::ReadFileToString(kZramGroupPath, &zram_file_content)) + return; + // The file contains a single significant character, possibly followed by + // newline. "x" means the user has opted out. "0" through "8" are the valid + // group names. (See src/platform/init/swap-exp.conf in chromiumos repo for + // group meanings.) + std::string zram_group = zram_file_content.substr(0, 1); + if (zram_group.compare("x") == 0) + return; + const base::FieldTrial::Probability kDivisor = 1; // on/off only + scoped_refptr<base::FieldTrial> trial = + base::FieldTrialList::FactoryGetFieldTrial( + "ZRAM", kDivisor, "default", 2013, 12, 31, NULL); + // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to + // all other choices. + const char* const kGroups[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" }; + bool matched = false; + for (size_t i = 0; i < arraysize(kGroups); ++i) { + bool match = zram_group.compare(kGroups[i]) == 0; + trial->AppendGroup(kGroups[i], match ? 1 : 0); + if (match) { + matched = true; + LOG(WARNING) << "zram field trial: group " << kGroups[i]; + } + } + if (!matched) + LOG(WARNING) << "zram field trial: invalid group \"" << zram_group << "\""; +} + } // namespace chromeos diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.h b/chrome/browser/chromeos/chrome_browser_main_chromeos.h index 9d848a9..0307305 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.h +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.h @@ -64,6 +64,7 @@ class ChromeBrowserMainPartsChromeos : public ChromeBrowserMainPartsLinux { private: // Set up field trial for low memory headroom settings. void SetupLowMemoryHeadroomFieldTrial(); + void SetupZramFieldTrial(); scoped_ptr<contacts::ContactManager> contact_manager_; scoped_ptr<BrightnessObserver> brightness_observer_; |