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

Side by Side Diff: chrome/browser/chromeos/chrome_browser_main_chromeos.cc

Issue 11744024: Add zram field trial (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address most comments by reviewers Created 7 years, 11 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
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.h ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/chrome_browser_main_chromeos.h" 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/chromeos/chromeos_version.h" 13 #include "base/chromeos/chromeos_version.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/file_util.h"
15 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
16 #include "base/linux_util.h" 17 #include "base/linux_util.h"
17 #include "base/message_loop.h" 18 #include "base/message_loop.h"
18 #include "base/string_number_conversions.h" 19 #include "base/string_number_conversions.h"
19 #include "base/string_split.h" 20 #include "base/string_split.h"
20 #include "chrome/browser/browser_process.h" 21 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" 22 #include "chrome/browser/chromeos/accessibility/accessibility_util.h"
22 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" 23 #include "chrome/browser/chromeos/accessibility/magnification_manager.h"
23 #include "chrome/browser/chromeos/audio/audio_handler.h" 24 #include "chrome/browser/chromeos/audio/audio_handler.h"
24 #include "chrome/browser/chromeos/boot_times_loader.h" 25 #include "chrome/browser/chromeos/boot_times_loader.h"
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 711
711 // Let the UserManager unregister itself as an observer of the CrosSettings 712 // Let the UserManager unregister itself as an observer of the CrosSettings
712 // singleton before it is destroyed. 713 // singleton before it is destroyed.
713 UserManager::Get()->Shutdown(); 714 UserManager::Get()->Shutdown();
714 715
715 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); 716 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun();
716 } 717 }
717 718
718 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { 719 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() {
719 SetupLowMemoryHeadroomFieldTrial(); 720 SetupLowMemoryHeadroomFieldTrial();
721 if (base::chromeos::IsRunningOnChromeOS())
722 // Run this on ChromeOS only because it tries to access /home/chronos.
723 SetupZramFieldTrial();
Ilya Sherman 2013/01/08 20:16:16 nit: Include curly braces for this if-stmt since i
Luigi Semenzato 2013/01/08 21:28:19 Thanks. The if has been removed.
720 } 724 }
721 725
722 void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() { 726 void ChromeBrowserMainPartsChromeos::SetupLowMemoryHeadroomFieldTrial() {
723 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); 727 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
724 // Only enable this experiment on Canary and Dev, since it's possible 728 // Only enable this experiment on Canary and Dev, since it's possible
725 // that this will make the machine unstable. 729 // that this will make the machine unstable.
726 // Note that to have this code execute in a developer build, 730 // Note that to have this code execute in a developer build,
727 // then chrome::VersionInfo::CHANNEL_UNKNOWN needs to be added here. 731 // then chrome::VersionInfo::CHANNEL_UNKNOWN needs to be added here.
728 if (channel == chrome::VersionInfo::CHANNEL_CANARY || 732 if (channel == chrome::VersionInfo::CHANNEL_CANARY ||
729 channel == chrome::VersionInfo::CHANNEL_DEV) { 733 channel == chrome::VersionInfo::CHANNEL_DEV) {
(...skipping 28 matching lines...) Expand all
758 LowMemoryObserver::SetLowMemoryMargin(100); 762 LowMemoryObserver::SetLowMemoryMargin(100);
759 } else if (trial->group() == margin_200mb) { 763 } else if (trial->group() == margin_200mb) {
760 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; 764 LOG(WARNING) << "low_mem: Part of '200MB' experiment";
761 LowMemoryObserver::SetLowMemoryMargin(200); 765 LowMemoryObserver::SetLowMemoryMargin(200);
762 } else { 766 } else {
763 LOG(WARNING) << "low_mem: Part of 'default' experiment"; 767 LOG(WARNING) << "low_mem: Part of 'default' experiment";
764 } 768 }
765 } 769 }
766 } 770 }
767 771
772
773 void ChromeBrowserMainPartsChromeos::SetupZramFieldTrial() {
774 // The dice for this experiment have been thrown at boot. The selected group
775 // number is stored in a file.
776 const FilePath kZramGroupPath("/home/chronos/.swap_exp_enrolled");
777 std::string zram_group;
778 // If the file does not exist, the experiment has not started. If the file
779 // exists but contains an "x", the user has a non-standard swap size and has
780 // been opted out.
781 if (!file_util::ReadFileToString(kZramGroupPath, &zram_group) ||
782 StartsWithASCII(zram_group, "x", true)) {
783 return;
784 }
785 const base::FieldTrial::Probability kDivisor = 1; // on/off only
786 scoped_refptr<base::FieldTrial> trial =
787 base::FieldTrialList::FactoryGetFieldTrial(
Alexei Svitkine (slow) 2013/01/08 20:30:47 Nit: Indent 4.
788 "ZRAM", kDivisor, "default", 2013, 12, 31, NULL);
Alexei Svitkine (slow) 2013/01/08 20:30:47 Nit: Also indent 4 from line above.
789 // Assign probability of 1 to the group Chrome OS has picked. Assign 0 to
790 // all other choices.
791 const char* const kGroups[] = { "0", "1", "2", "3", "4", "5", "6", "7", "8" };
Alexei Svitkine (slow) 2013/01/08 20:38:02 Note: I saw your earlier concern about whether the
Luigi Semenzato 2013/01/08 21:28:19 Good to know, thanks.
792 for (unsigned int i = 0; i < arraysize(kGroups); i++) {
Ilya Sherman 2013/01/08 20:16:16 nit: Still ++i ;)
Luigi Semenzato 2013/01/08 21:28:19 Aw!
793 bool match = StartsWithASCII(zram_group, kGroups[i], true);
Alexei Svitkine (slow) 2013/01/08 20:30:47 I don't know the details of how that file is creat
Alexei Svitkine (slow) 2013/01/08 20:38:02 I notice this was somewhat covered by earlier disc
Greg Spencer (Chromium) 2013/01/08 20:41:03 No, we don't run Debug builds on any channels: the
Alexei Svitkine (slow) 2013/01/08 20:44:05 DCHECKs can be enabled in release builds though, w
794 trial->AppendGroup(kGroups[i], match ? 1 : 0);
795 if (match)
796 LOG(WARNING) << "zram field trial: group " << groups[i];
797 }
798 }
799
768 } // namespace chromeos 800 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/chrome_browser_main_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698