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

Side by Side Diff: chrome/browser/chrome_browser_field_trials.cc

Issue 2647353003: Make LocalMemory (aka InMemory) the default for persistent histograms. (Closed)
Patch Set: make LocalMemory be the default for now Created 3 years, 10 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 | « no previous file | 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/chrome_browser_field_trials.h" 5 #include "chrome/browser/chrome_browser_field_trials.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 InitResult result; 66 InitResult result;
67 67
68 // Create persistent/shared memory and allow histograms to be stored in 68 // Create persistent/shared memory and allow histograms to be stored in
69 // it. Memory that is not actualy used won't be physically mapped by the 69 // it. Memory that is not actualy used won't be physically mapped by the
70 // system. BrowserMetrics usage, as reported in UMA, peaked around 3.0MiB 70 // system. BrowserMetrics usage, as reported in UMA, peaked around 3.0MiB
71 // as of 2016-12-20. 71 // as of 2016-12-20.
72 const size_t kAllocSize = 5 << 20; // 5 MiB 72 const size_t kAllocSize = 5 << 20; // 5 MiB
73 const uint32_t kAllocId = 0x935DDD43; // SHA1(BrowserMetrics) 73 const uint32_t kAllocId = 0x935DDD43; // SHA1(BrowserMetrics)
74 std::string storage = variations::GetVariationParamValueByFeature( 74 std::string storage = variations::GetVariationParamValueByFeature(
75 base::kPersistentHistogramsFeature, "storage"); 75 base::kPersistentHistogramsFeature, "storage");
76
76 if (storage == "MappedFile") { 77 if (storage == "MappedFile") {
77 // If for some reason the existing "active" file could not be moved above 78 // If for some reason the existing "active" file could not be moved above
78 // then it is essential it be scheduled for deletion when possible and the 79 // then it is essential it be scheduled for deletion when possible and the
79 // contents ignored. Because this shouldn't happen but can on an OS like 80 // contents ignored. Because this shouldn't happen but can on an OS like
80 // Windows where another process reading the file (backup, AV, etc.) can 81 // Windows where another process reading the file (backup, AV, etc.) can
81 // prevent its alteration, it's necessary to handle this case by switching 82 // prevent its alteration, it's necessary to handle this case by switching
82 // to the equivalent of "LocalMemory" for this run. 83 // to the equivalent of "LocalMemory" for this run.
83 if (base::PathExists(active_file)) { 84 if (base::PathExists(active_file)) {
84 base::File file(active_file, base::File::FLAG_OPEN | 85 base::File file(active_file, base::File::FLAG_OPEN |
85 base::File::FLAG_READ | 86 base::File::FLAG_READ |
86 base::File::FLAG_DELETE_ON_CLOSE); 87 base::File::FLAG_DELETE_ON_CLOSE);
87 result = MAPPED_FILE_EXISTS; 88 result = MAPPED_FILE_EXISTS;
88 base::GlobalHistogramAllocator::CreateWithLocalMemory( 89 base::GlobalHistogramAllocator::CreateWithLocalMemory(
89 kAllocSize, kAllocId, 90 kAllocSize, kAllocId,
90 ChromeMetricsServiceClient::kBrowserMetricsName); 91 ChromeMetricsServiceClient::kBrowserMetricsName);
91 } else { 92 } else {
92 // Create global allocator with the "active" file. 93 // Create global allocator with the "active" file.
93 if (base::GlobalHistogramAllocator::CreateWithFile( 94 if (base::GlobalHistogramAllocator::CreateWithFile(
94 active_file, kAllocSize, kAllocId, 95 active_file, kAllocSize, kAllocId,
95 ChromeMetricsServiceClient::kBrowserMetricsName)) { 96 ChromeMetricsServiceClient::kBrowserMetricsName)) {
96 result = MAPPED_FILE_SUCCESS; 97 result = MAPPED_FILE_SUCCESS;
97 } else { 98 } else {
98 result = MAPPED_FILE_FAILED; 99 result = MAPPED_FILE_FAILED;
99 } 100 }
100 } 101 }
101 } else if (storage == "LocalMemory") { 102 } else if (storage.empty() || storage == "LocalMemory") {
102 // Use local memory for storage even though it will not persist across 103 // Use local memory for storage even though it will not persist across
103 // an unclean shutdown. 104 // an unclean shutdown.
104 base::GlobalHistogramAllocator::CreateWithLocalMemory( 105 base::GlobalHistogramAllocator::CreateWithLocalMemory(
105 kAllocSize, kAllocId, ChromeMetricsServiceClient::kBrowserMetricsName); 106 kAllocSize, kAllocId, ChromeMetricsServiceClient::kBrowserMetricsName);
106 result = LOCAL_MEMORY_SUCCESS; 107 result = LOCAL_MEMORY_SUCCESS;
107 } else { 108 } else {
108 // Persistent metric storage is disabled. 109 // Persistent metric storage is disabled.
109 return; 110 return;
110 } 111 }
111 112
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 bool has_seed, 165 bool has_seed,
165 base::FeatureList* feature_list) { 166 base::FeatureList* feature_list) {
166 CreateFallbackSamplingTrialIfNeeded(has_seed, feature_list); 167 CreateFallbackSamplingTrialIfNeeded(has_seed, feature_list);
167 } 168 }
168 169
169 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() { 170 void ChromeBrowserFieldTrials::InstantiateDynamicTrials() {
170 // Persistent histograms must be enabled as soon as possible. 171 // Persistent histograms must be enabled as soon as possible.
171 InstantiatePersistentHistograms(); 172 InstantiatePersistentHistograms();
172 tracing::SetupBackgroundTracingFieldTrial(); 173 tracing::SetupBackgroundTracingFieldTrial();
173 } 174 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698