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

Side by Side Diff: chrome/browser/task_manager/sampling/task_group_sampler.cc

Issue 2740423002: mac: Fix calulation for number of resident pages in a process. (Closed)
Patch Set: Created 3 years, 9 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/task_manager/sampling/task_group_sampler.h" 5 #include "chrome/browser/task_manager/sampling/task_group_sampler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence()); 119 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence());
120 120
121 return process_metrics_->GetCPUUsage(); 121 return process_metrics_->GetCPUUsage();
122 } 122 }
123 123
124 MemoryUsageStats TaskGroupSampler::RefreshMemoryUsage() { 124 MemoryUsageStats TaskGroupSampler::RefreshMemoryUsage() {
125 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence()); 125 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence());
126 126
127 MemoryUsageStats memory_usage; 127 MemoryUsageStats memory_usage;
128 #if defined(OS_MACOSX) 128 #if defined(OS_MACOSX)
129 memory_usage.physical_bytes =
Mark Mentovai 2017/03/13 18:13:33 Leaving this alone was nice because it consolidate
ssid 2017/03/13 18:44:55 Yes, the main consumer of this number I'd expect w
Mark Mentovai 2017/03/13 18:48:03 ssid wrote:
ssid 2017/03/13 18:59:14 Um sorry, yes I just felt showing different number
erikchen 2017/03/13 21:00:41 Calculating private/shared bytes has a performance
130 static_cast<int64_t>(process_metrics_->GetWorkingSetSize());
131
132 size_t private_bytes = 0; 129 size_t private_bytes = 0;
133 size_t shared_bytes = 0; 130 size_t shared_bytes = 0;
134 if (process_metrics_->GetMemoryBytes(&private_bytes, &shared_bytes)) { 131 if (process_metrics_->GetMemoryBytes(&private_bytes, &shared_bytes)) {
135 memory_usage.private_bytes = static_cast<int64_t>(private_bytes); 132 memory_usage.private_bytes = static_cast<int64_t>(private_bytes);
136 memory_usage.shared_bytes = static_cast<int64_t>(shared_bytes); 133 memory_usage.shared_bytes = static_cast<int64_t>(shared_bytes);
134 memory_usage.physical_bytes =
135 memory_usage.private_bytes + memory_usage.shared_bytes;
137 } 136 }
138 #else 137 #else
139 // Refreshing the physical/private/shared memory at one shot. 138 // Refreshing the physical/private/shared memory at one shot.
140 base::WorkingSetKBytes ws_usage; 139 base::WorkingSetKBytes ws_usage;
141 if (process_metrics_->GetWorkingSetKBytes(&ws_usage)) { 140 if (process_metrics_->GetWorkingSetKBytes(&ws_usage)) {
142 memory_usage.private_bytes = static_cast<int64_t>(ws_usage.priv * 1024); 141 memory_usage.private_bytes = static_cast<int64_t>(ws_usage.priv * 1024);
143 memory_usage.shared_bytes = static_cast<int64_t>(ws_usage.shared * 1024); 142 memory_usage.shared_bytes = static_cast<int64_t>(ws_usage.shared * 1024);
144 #if defined(OS_LINUX) 143 #if defined(OS_LINUX)
145 // On Linux private memory is also resident. Just use it. 144 // On Linux private memory is also resident. Just use it.
146 memory_usage.physical_bytes = memory_usage.private_bytes; 145 memory_usage.physical_bytes = memory_usage.private_bytes;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence()); 182 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequence());
184 #if defined(OS_MACOSX) 183 #if defined(OS_MACOSX)
185 return process_.IsProcessBackgrounded( 184 return process_.IsProcessBackgrounded(
186 content::BrowserChildProcessHost::GetPortProvider()); 185 content::BrowserChildProcessHost::GetPortProvider());
187 #else 186 #else
188 return process_.IsProcessBackgrounded(); 187 return process_.IsProcessBackgrounded();
189 #endif // defined(OS_MACOSX) 188 #endif // defined(OS_MACOSX)
190 } 189 }
191 190
192 } // namespace task_manager 191 } // namespace task_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698