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

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

Issue 1688963002: UMA stats to count RenderFrameProxyHosts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@uma2
Patch Set: Charlie's fixes Created 4 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 | « chrome/browser/site_details.h ('k') | chrome/browser/site_details_browsertest.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/site_details.h" 5 #include "chrome/browser/site_details.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "content/public/browser/browser_thread.h" 8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/render_frame_host.h" 9 #include "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/render_process_host.h" 10 #include "content/public/browser/render_process_host.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } // namespace 83 } // namespace
84 84
85 ScenarioBrowsingInstanceInfo::ScenarioBrowsingInstanceInfo() {} 85 ScenarioBrowsingInstanceInfo::ScenarioBrowsingInstanceInfo() {}
86 86
87 ScenarioBrowsingInstanceInfo::~ScenarioBrowsingInstanceInfo() {} 87 ScenarioBrowsingInstanceInfo::~ScenarioBrowsingInstanceInfo() {}
88 88
89 BrowsingInstanceInfo::BrowsingInstanceInfo() {} 89 BrowsingInstanceInfo::BrowsingInstanceInfo() {}
90 90
91 BrowsingInstanceInfo::~BrowsingInstanceInfo() {} 91 BrowsingInstanceInfo::~BrowsingInstanceInfo() {}
92 92
93 IsolationScenario::IsolationScenario() : policy(ISOLATE_ALL_SITES) {} 93 IsolationScenario::IsolationScenario() {}
94 94
95 IsolationScenario::~IsolationScenario() {} 95 IsolationScenario::~IsolationScenario() {}
96 96
97 SiteData::SiteData() : out_of_process_frames(0) { 97 SiteData::SiteData() {
98 for (int i = 0; i <= ISOLATION_SCENARIO_LAST; i++) 98 for (int i = 0; i <= ISOLATION_SCENARIO_LAST; i++)
99 scenarios[i].policy = static_cast<IsolationScenarioType>(i); 99 scenarios[i].policy = static_cast<IsolationScenarioType>(i);
100 } 100 }
101 101
102 SiteData::~SiteData() {} 102 SiteData::~SiteData() {}
103 103
104 SiteDetails::SiteDetails() {} 104 SiteDetails::SiteDetails() {}
105 105
106 SiteDetails::~SiteDetails() {} 106 SiteDetails::~SiteDetails() {}
107 107
108 void SiteDetails::CollectSiteInfo(WebContents* contents, 108 void SiteDetails::CollectSiteInfo(WebContents* contents,
109 SiteData* site_data) { 109 SiteData* site_data) {
110 DCHECK_CURRENTLY_ON(BrowserThread::UI); 110 DCHECK_CURRENTLY_ON(BrowserThread::UI);
111 BrowserContext* context = contents->GetBrowserContext();
112
113 // The primary should be the same for the whole tab.
111 SiteInstance* primary = 114 SiteInstance* primary =
112 DeterminePrimarySiteInstance(contents->GetSiteInstance(), site_data); 115 DeterminePrimarySiteInstance(contents->GetSiteInstance(), site_data);
113 BrowserContext* context = primary->GetBrowserContext(); 116 BrowsingInstanceInfo* browsing_instance =
117 &site_data->browsing_instances[primary];
118
119 for (RenderFrameHost* frame : contents->GetAllFrames()) {
120 // Ensure that we add the frame's SiteInstance to |site_instances|.
121 DCHECK(frame->GetSiteInstance()->IsRelatedSiteInstance(primary));
122 browsing_instance->site_instances.insert(frame->GetSiteInstance());
123 browsing_instance->proxy_count += frame->GetProxyCount();
124
125 if (frame->GetParent()) {
126 if (frame->GetSiteInstance() != frame->GetParent()->GetSiteInstance())
127 site_data->out_of_process_frames++;
128 }
129 }
114 130
115 // Now keep track of how many sites we have in this BrowsingInstance (and 131 // Now keep track of how many sites we have in this BrowsingInstance (and
116 // overall), including sites in iframes. 132 // overall), including sites in iframes.
117 for (IsolationScenario& scenario : site_data->scenarios) { 133 for (IsolationScenario& scenario : site_data->scenarios) {
118 std::map<RenderFrameHost*, GURL> frame_urls; 134 std::map<RenderFrameHost*, GURL> frame_urls;
119 for (RenderFrameHost* frame : contents->GetAllFrames()) { 135 for (RenderFrameHost* frame : contents->GetAllFrames()) {
120 // Determine the site from the frame's origin, with a fallback to the 136 // Determine the site from the frame's origin, with a fallback to the
121 // frame's URL. In cases like <iframe sandbox>, we can wind up with an 137 // frame's URL. In cases like <iframe sandbox>, we can wind up with an
122 // http URL but a unique origin. The origin of the resource will still 138 // http URL but a unique origin. The origin of the resource will still
123 // determine process placement. 139 // determine process placement.
(...skipping 24 matching lines...) Expand all
148 // We model process-per-site by only inserting those sites into the first 164 // We model process-per-site by only inserting those sites into the first
149 // browsing instance in which they appear. 165 // browsing instance in which they appear.
150 if (scenario.all_sites.insert(site).second || !process_per_site) 166 if (scenario.all_sites.insert(site).second || !process_per_site)
151 scenario.browsing_instances[primary->GetId()].sites.insert(site); 167 scenario.browsing_instances[primary->GetId()].sites.insert(site);
152 168
153 // Record our result in |frame_urls| for use by children. 169 // Record our result in |frame_urls| for use by children.
154 frame_urls[frame] = site; 170 frame_urls[frame] = site;
155 } 171 }
156 } 172 }
157 173
158 for (RenderFrameHost* frame : contents->GetAllFrames()) {
159 if (frame->GetParent()) {
160 if (frame->GetSiteInstance() != frame->GetParent()->GetSiteInstance())
161 site_data->out_of_process_frames++;
162 }
163 DeterminePrimarySiteInstance(frame->GetSiteInstance(), site_data);
164 }
165 } 174 }
166 175
167 void SiteDetails::UpdateHistograms( 176 void SiteDetails::UpdateHistograms(
168 const BrowserContextSiteDataMap& site_data_map, 177 const BrowserContextSiteDataMap& site_data_map,
169 int all_renderer_process_count, 178 int all_renderer_process_count,
170 int non_renderer_process_count) { 179 int non_renderer_process_count) {
171 // Reports a set of site-based process metrics to UMA. 180 // Reports a set of site-based process metrics to UMA.
172 int process_limit = RenderProcessHost::GetMaxRendererProcessCount(); 181 int process_limit = RenderProcessHost::GetMaxRendererProcessCount();
173 182
174 // Sum the number of sites and SiteInstances in each BrowserContext and 183 // Sum the number of sites and SiteInstances in each BrowserContext and
175 // the total number of out-of-process iframes. 184 // the total number of out-of-process iframes.
176 int num_sites[ISOLATION_SCENARIO_LAST + 1] = {}; 185 int num_sites[ISOLATION_SCENARIO_LAST + 1] = {};
177 int num_isolated_site_instances[ISOLATION_SCENARIO_LAST + 1] = {}; 186 int num_isolated_site_instances[ISOLATION_SCENARIO_LAST + 1] = {};
178 int num_browsing_instances = 0; 187 int num_browsing_instances = 0;
179 int num_oopifs = 0; 188 int num_oopifs = 0;
189 int num_proxies = 0;
180 for (auto& site_data_map_entry : site_data_map) { 190 for (auto& site_data_map_entry : site_data_map) {
181 const SiteData& site_data = site_data_map_entry.second; 191 const SiteData& site_data = site_data_map_entry.second;
182 for (const IsolationScenario& scenario : site_data.scenarios) { 192 for (const IsolationScenario& scenario : site_data.scenarios) {
183 num_sites[scenario.policy] += scenario.all_sites.size(); 193 num_sites[scenario.policy] += scenario.all_sites.size();
184 for (auto& entry : scenario.browsing_instances) { 194 for (auto& entry : scenario.browsing_instances) {
185 const ScenarioBrowsingInstanceInfo& scenario_browsing_instance_info = 195 const ScenarioBrowsingInstanceInfo& scenario_browsing_instance_info =
186 entry.second; 196 entry.second;
187 num_isolated_site_instances[scenario.policy] += 197 num_isolated_site_instances[scenario.policy] +=
188 scenario_browsing_instance_info.sites.size(); 198 scenario_browsing_instance_info.sites.size();
189 } 199 }
190 } 200 }
191 for (const auto& entry : site_data.browsing_instances) { 201 for (const auto& entry : site_data.browsing_instances) {
192 const BrowsingInstanceInfo& browsing_instance_info = entry.second; 202 const BrowsingInstanceInfo& browsing_instance_info = entry.second;
193 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.SiteInstancesPerBrowsingInstance", 203 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.SiteInstancesPerBrowsingInstance",
194 browsing_instance_info.site_instances.size()); 204 browsing_instance_info.site_instances.size());
205 UMA_HISTOGRAM_COUNTS_10000("SiteIsolation.ProxyCountPerBrowsingInstance",
206 browsing_instance_info.proxy_count);
207 num_proxies += browsing_instance_info.proxy_count;
195 } 208 }
196 num_browsing_instances += site_data.browsing_instances.size(); 209 num_browsing_instances += site_data.browsing_instances.size();
197 num_oopifs += site_data.out_of_process_frames; 210 num_oopifs += site_data.out_of_process_frames;
198 } 211 }
199 212
200 // Predict the number of processes needed when isolating all sites, when 213 // Predict the number of processes needed when isolating all sites, when
201 // isolating only HTTPS sites, and when isolating extensions. 214 // isolating only HTTPS sites, and when isolating extensions.
202 int process_count_lower_bound[ISOLATION_SCENARIO_LAST + 1]; 215 int process_count_lower_bound[ISOLATION_SCENARIO_LAST + 1];
203 int process_count_upper_bound[ISOLATION_SCENARIO_LAST + 1]; 216 int process_count_upper_bound[ISOLATION_SCENARIO_LAST + 1];
204 int process_count_estimate[ISOLATION_SCENARIO_LAST + 1]; 217 int process_count_estimate[ISOLATION_SCENARIO_LAST + 1];
205 for (int policy = 0; policy <= ISOLATION_SCENARIO_LAST; policy++) { 218 for (int policy = 0; policy <= ISOLATION_SCENARIO_LAST; policy++) {
206 process_count_lower_bound[policy] = num_sites[policy]; 219 process_count_lower_bound[policy] = num_sites[policy];
207 process_count_upper_bound[policy] = num_sites[policy] + process_limit - 1; 220 process_count_upper_bound[policy] = num_sites[policy] + process_limit - 1;
208 process_count_estimate[policy] = std::min( 221 process_count_estimate[policy] = std::min(
209 num_isolated_site_instances[policy], process_count_upper_bound[policy]); 222 num_isolated_site_instances[policy], process_count_upper_bound[policy]);
210 } 223 }
211 224
212 // Just renderer process count: 225 // Just renderer process count:
213 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.CurrentRendererProcessCount", 226 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.CurrentRendererProcessCount",
214 all_renderer_process_count); 227 all_renderer_process_count);
215 UMA_HISTOGRAM_COUNTS_100( 228 UMA_HISTOGRAM_COUNTS_100(
216 "SiteIsolation.BrowsingInstanceCount", 229 "SiteIsolation.BrowsingInstanceCount",
217 num_browsing_instances); 230 num_browsing_instances);
231 UMA_HISTOGRAM_COUNTS_10000("SiteIsolation.ProxyCount", num_proxies);
218 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.OutOfProcessIframes", num_oopifs); 232 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.OutOfProcessIframes", num_oopifs);
219 233
220 // ISOLATE_NOTHING metrics. 234 // ISOLATE_NOTHING metrics.
221 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountNoLimit", 235 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountNoLimit",
222 num_isolated_site_instances[ISOLATE_NOTHING]); 236 num_isolated_site_instances[ISOLATE_NOTHING]);
223 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountLowerBound", 237 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountLowerBound",
224 process_count_lower_bound[ISOLATE_NOTHING]); 238 process_count_lower_bound[ISOLATE_NOTHING]);
225 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountEstimate", 239 UMA_HISTOGRAM_COUNTS_100("SiteIsolation.IsolateNothingProcessCountEstimate",
226 process_count_estimate[ISOLATE_NOTHING]); 240 process_count_estimate[ISOLATE_NOTHING]);
227 UMA_HISTOGRAM_COUNTS_100( 241 UMA_HISTOGRAM_COUNTS_100(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 UMA_HISTOGRAM_COUNTS_100( 273 UMA_HISTOGRAM_COUNTS_100(
260 "SiteIsolation.IsolateExtensionsProcessCountLowerBound", 274 "SiteIsolation.IsolateExtensionsProcessCountLowerBound",
261 process_count_lower_bound[ISOLATE_EXTENSIONS]); 275 process_count_lower_bound[ISOLATE_EXTENSIONS]);
262 UMA_HISTOGRAM_COUNTS_100( 276 UMA_HISTOGRAM_COUNTS_100(
263 "SiteIsolation.IsolateExtensionsProcessCountEstimate", 277 "SiteIsolation.IsolateExtensionsProcessCountEstimate",
264 process_count_estimate[ISOLATE_EXTENSIONS]); 278 process_count_estimate[ISOLATE_EXTENSIONS]);
265 UMA_HISTOGRAM_COUNTS_100( 279 UMA_HISTOGRAM_COUNTS_100(
266 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate", 280 "SiteIsolation.IsolateExtensionsTotalProcessCountEstimate",
267 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count); 281 process_count_estimate[ISOLATE_EXTENSIONS] + non_renderer_process_count);
268 } 282 }
OLDNEW
« no previous file with comments | « chrome/browser/site_details.h ('k') | chrome/browser/site_details_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698