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

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

Issue 1994653006: Fix the views Task Manager on Mac showing 0s for the Shared Memory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile errors Created 4 years, 7 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 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_management/sampling/task_group_sampler.h" 5 #include "chrome/browser/task_management/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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 double TaskGroupSampler::RefreshCpuUsage() { 116 double TaskGroupSampler::RefreshCpuUsage() {
117 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread()); 117 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread());
118 118
119 return process_metrics_->GetCPUUsage(); 119 return process_metrics_->GetCPUUsage();
120 } 120 }
121 121
122 MemoryUsageStats TaskGroupSampler::RefreshMemoryUsage() { 122 MemoryUsageStats TaskGroupSampler::RefreshMemoryUsage() {
123 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread()); 123 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread());
124 124
125 // TODO(afakhry): Integrate Bruce's CL for faster retrieval of physical memory 125 MemoryUsageStats memory_usage;
126 // on Windows here. 126 #if defined(OS_MACOSX)
127 memory_usage.physical_bytes =
128 static_cast<int64_t>(process_metrics_->GetWorkingSetSize());
127 129
128 MemoryUsageStats memory_usage; 130 size_t private_bytes = 0;
131 size_t shared_bytes = 0;
132 if (process_metrics_->GetMemoryBytes(&private_bytes, &shared_bytes)) {
133 memory_usage.private_bytes = static_cast<int64_t>(private_bytes);
134 memory_usage.shared_bytes = static_cast<int64_t>(shared_bytes);
135 }
136 #else
129 // Refreshing the physical/private/shared memory at one shot. 137 // Refreshing the physical/private/shared memory at one shot.
130 base::WorkingSetKBytes ws_usage; 138 base::WorkingSetKBytes ws_usage;
131 if (process_metrics_->GetWorkingSetKBytes(&ws_usage)) { 139 if (process_metrics_->GetWorkingSetKBytes(&ws_usage)) {
132 memory_usage.private_bytes = static_cast<int64_t>(ws_usage.priv * 1024); 140 memory_usage.private_bytes = static_cast<int64_t>(ws_usage.priv * 1024);
133 memory_usage.shared_bytes = static_cast<int64_t>(ws_usage.shared * 1024); 141 memory_usage.shared_bytes = static_cast<int64_t>(ws_usage.shared * 1024);
134 #if defined(OS_LINUX) 142 #if defined(OS_LINUX)
135 // On Linux private memory is also resident. Just use it. 143 // On Linux private memory is also resident. Just use it.
136 memory_usage.physical_bytes = memory_usage.private_bytes; 144 memory_usage.physical_bytes = memory_usage.private_bytes;
137 #else 145 #else
138 // Memory = working_set.private which is working set minus shareable. This 146 // Memory = working_set.private which is working set minus shareable. This
139 // avoids the unpredictable counting that occurs when calculating memory as 147 // avoids the unpredictable counting that occurs when calculating memory as
140 // working set minus shared (renderer code counted when one tab is open and 148 // working set minus shared (renderer code counted when one tab is open and
141 // not counted when two or more are open) and it is much more efficient to 149 // not counted when two or more are open) and it is much more efficient to
142 // calculate on Windows. 150 // calculate on Windows.
143 memory_usage.physical_bytes = 151 memory_usage.physical_bytes =
144 static_cast<int64_t>(process_metrics_->GetWorkingSetSize()); 152 static_cast<int64_t>(process_metrics_->GetWorkingSetSize());
145 memory_usage.physical_bytes -= 153 memory_usage.physical_bytes -=
146 static_cast<int64_t>(ws_usage.shareable * 1024); 154 static_cast<int64_t>(ws_usage.shareable * 1024);
147 #endif 155 #endif // defined(OS_LINUX)
156
148 #if defined(OS_CHROMEOS) 157 #if defined(OS_CHROMEOS)
149 memory_usage.swapped_bytes = ws_usage.swapped * 1024; 158 memory_usage.swapped_bytes = ws_usage.swapped * 1024;
150 #endif 159 #endif // defined(OS_CHROMEOS)
151 } 160 }
161 #endif // defined(OS_MACOSX)
152 162
153 return memory_usage; 163 return memory_usage;
154 } 164 }
155 165
156 int TaskGroupSampler::RefreshIdleWakeupsPerSecond() { 166 int TaskGroupSampler::RefreshIdleWakeupsPerSecond() {
157 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread()); 167 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread());
158 168
159 return process_metrics_->GetIdleWakeupsPerSecond(); 169 return process_metrics_->GetIdleWakeupsPerSecond();
160 } 170 }
161 171
162 #if defined(OS_LINUX) 172 #if defined(OS_LINUX)
163 int TaskGroupSampler::RefreshOpenFdCount() { 173 int TaskGroupSampler::RefreshOpenFdCount() {
164 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread()); 174 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread());
165 175
166 return process_metrics_->GetOpenFdCount(); 176 return process_metrics_->GetOpenFdCount();
167 } 177 }
168 #endif // defined(OS_LINUX) 178 #endif // defined(OS_LINUX)
169 179
170 bool TaskGroupSampler::RefreshProcessPriority() { 180 bool TaskGroupSampler::RefreshProcessPriority() {
171 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread()); 181 DCHECK(worker_pool_sequenced_checker_.CalledOnValidSequencedThread());
172 182
173 return process_.IsProcessBackgrounded(); 183 return process_.IsProcessBackgrounded();
174 } 184 }
175 185
176 } // namespace task_management 186 } // namespace task_management
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