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

Issue 2824133002: Record swap metrics (Closed)

Created:
3 years, 8 months ago by bashi
Modified:
3 years, 7 months ago
CC:
chromium-reviews, chrome-grc-reviews+memory_chromium.org, darin-cc_chromium.org, asvitkine+watch_chromium.org, mac-reviews_chromium.org
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Record swap metrics This CL adds SwapMetricsObserver which records swap rates and reports them as platform-specific metrics. The purpose of adding these metrics is to measure the impact of actions we take to free up memory. If we aggressively free up memory under high memory pressure, we may touch pages which are already swapped out (or compressed). In such cases thrashing could happen and we are making the situation worse. Swap rates and page compression/decompression rate would be good indicators of thrashing. Metrics will be recorded every 60 seconds. This CL only adds metrics for Android/ChromeOS/Linux. Follow-up CLs will add them for macOS. BUG=617492 Review-Url: https://codereview.chromium.org/2824133002 Cr-Commit-Position: refs/heads/master@{#468266} Committed: https://chromium.googlesource.com/chromium/src/+/4159f36e93c398b9816b734a14e97220e83fc912

Patch Set 1 #

Total comments: 11

Patch Set 2 : comments #

Total comments: 4

Patch Set 3 : comments #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+242 lines, -0 lines) Patch
M content/browser/BUILD.gn View 1 2 2 chunks +14 lines, -0 lines 0 comments Download
M content/browser/browser_main_loop.cc View 1 2 2 chunks +5 lines, -0 lines 0 comments Download
A content/browser/memory/swap_metrics_observer.h View 1 1 chunk +53 lines, -0 lines 0 comments Download
A content/browser/memory/swap_metrics_observer.cc View 1 2 1 chunk +43 lines, -0 lines 0 comments Download
A content/browser/memory/swap_metrics_observer_linux.h View 1 1 chunk +27 lines, -0 lines 0 comments Download
A content/browser/memory/swap_metrics_observer_linux.cc View 1 1 chunk +55 lines, -0 lines 0 comments Download
A content/browser/memory/swap_metrics_observer_mac.cc View 1 chunk +15 lines, -0 lines 0 comments Download
A content/browser/memory/swap_metrics_observer_win.cc View 1 1 chunk +16 lines, -0 lines 2 comments Download
M tools/metrics/histograms/histograms.xml View 1 2 1 chunk +14 lines, -0 lines 0 comments Download

Messages

Total messages: 35 (18 generated)
bashi
I tried some ideas to record swapping and page compression behavior and ended up using ...
3 years, 8 months ago (2017-04-18 07:12:33 UTC) #5
haraken
I might want to get some OS experts to review this CL. shrike@, primiano@, erikchen@: ...
3 years, 8 months ago (2017-04-18 08:04:25 UTC) #9
erikchen
https://codereview.chromium.org/2824133002/diff/1/content/browser/memory/swap_metrics_observer_mac.cc File content/browser/memory/swap_metrics_observer_mac.cc (right): https://codereview.chromium.org/2824133002/diff/1/content/browser/memory/swap_metrics_observer_mac.cc#newcode11 content/browser/memory/swap_metrics_observer_mac.cc:11: // TODO(bashi): Implement SwapMetricsObserver for macOS. You'll want to ...
3 years, 8 months ago (2017-04-18 17:48:19 UTC) #10
bashi
Any feedback? I guess that experts have better ideas :) https://codereview.chromium.org/2824133002/diff/1/content/browser/memory/swap_metrics_observer_mac.cc File content/browser/memory/swap_metrics_observer_mac.cc (right): https://codereview.chromium.org/2824133002/diff/1/content/browser/memory/swap_metrics_observer_mac.cc#newcode11 ...
3 years, 8 months ago (2017-04-20 01:32:04 UTC) #11
bashi
Hi reviewers, Can I proceed with this approach to measure swap rates? Or should GRC ...
3 years, 8 months ago (2017-04-27 04:36:45 UTC) #13
haraken
On 2017/04/27 04:36:45, bashi wrote: > Hi reviewers, > > Can I proceed with this ...
3 years, 8 months ago (2017-04-27 04:46:16 UTC) #14
Primiano Tucci (use gerrit)
content/browser/memory/swap_metrics_observer_linux.* LGTM Did you try if this works on Android (just wondering if reading /proc/vmstat ...
3 years, 7 months ago (2017-04-27 10:01:20 UTC) #15
bashi
Thanks Primiano for review. > Did you try if this works on Android (just wondering ...
3 years, 7 months ago (2017-04-28 02:05:35 UTC) #16
haraken
LGTM
3 years, 7 months ago (2017-04-28 02:30:47 UTC) #17
bashi
jam@: could you review content/browser? isherman@: could you review histograms.xml?
3 years, 7 months ago (2017-04-28 05:31:45 UTC) #19
jam
On 2017/04/28 05:31:45, bashi wrote: > jam@: could you review content/browser? > isherman@: could you ...
3 years, 7 months ago (2017-04-28 15:45:34 UTC) #20
Ilya Sherman
Metrics LGTM % nits: https://codereview.chromium.org/2824133002/diff/20001/content/browser/memory/swap_metrics_observer.cc File content/browser/memory/swap_metrics_observer.cc (right): https://codereview.chromium.org/2824133002/diff/20001/content/browser/memory/swap_metrics_observer.cc#newcode16 content/browser/memory/swap_metrics_observer.cc:16: } nit: Please leave a ...
3 years, 7 months ago (2017-04-28 21:10:20 UTC) #21
bashi
https://codereview.chromium.org/2824133002/diff/20001/content/browser/memory/swap_metrics_observer.cc File content/browser/memory/swap_metrics_observer.cc (right): https://codereview.chromium.org/2824133002/diff/20001/content/browser/memory/swap_metrics_observer.cc#newcode16 content/browser/memory/swap_metrics_observer.cc:16: } On 2017/04/28 21:10:20, Ilya Sherman wrote: > nit: ...
3 years, 7 months ago (2017-05-01 01:14:13 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2824133002/40001
3 years, 7 months ago (2017-05-01 01:14:38 UTC) #29
commit-bot: I haz the power
Committed patchset #3 (id:40001) as https://chromium.googlesource.com/chromium/src/+/4159f36e93c398b9816b734a14e97220e83fc912
3 years, 7 months ago (2017-05-01 01:20:10 UTC) #33
chrisha
https://codereview.chromium.org/2824133002/diff/40001/content/browser/memory/swap_metrics_observer_win.cc File content/browser/memory/swap_metrics_observer_win.cc (right): https://codereview.chromium.org/2824133002/diff/40001/content/browser/memory/swap_metrics_observer_win.cc#newcode12 content/browser/memory/swap_metrics_observer_win.cc:12: // TODO(bashi): Figure out a way to measure swap ...
3 years, 7 months ago (2017-05-03 15:55:57 UTC) #34
bashi
3 years, 7 months ago (2017-05-08 05:52:00 UTC) #35
Message was sent while issue was closed.
https://codereview.chromium.org/2824133002/diff/40001/content/browser/memory/...
File content/browser/memory/swap_metrics_observer_win.cc (right):

https://codereview.chromium.org/2824133002/diff/40001/content/browser/memory/...
content/browser/memory/swap_metrics_observer_win.cc:12: // TODO(bashi): Figure
out a way to measure swap rates on Windows.
On 2017/05/03 15:55:56, chrisha wrote:
> You can find detailed stats for a particular process (CoW faults, soft faults,
> hard faults, file cache faults, etc) via undocumented NT internals:
> NtQuerySystemInformation and SYSTEM_PERFORMANCE_INFORMATION. We have similar
> code using this kind of functionality here:
> 
>
https://cs.chromium.org/chromium/src/components/startup_metric_utils/browser/...
> 
> You can get system wide performance counters in various ways. There are many
> "undocumented" structures that contain performance data, including:
> 
> VM_COUNTERS, SYSTEM_FILECACHE_INFORMATION, SYSTEM_MEMORY_USAGE,
> SYSTEM_PAGEFILE_INFORMATION, SYSTEM_PERFORMANCE_INFORMATION_2 (extremely
> detailed), SYSTEM_BASIC_PERFORMANCE_INFORMATION, SYSTEM_BASIC_INFORMATION_EX
> 
> There's also a whole "performance counter" API. This wraps many of the NT
> internals, and is much slower but much more clearly documented. See
> PdhOpenQuery, PdhAddCounter, PdhGetCounterInfo, PdhGetFormattedCounterInfo,
> PdhCloseQuery.
> 
> Some experimentation needs to be done to figure out which NT internals are the
> exact counters you want, when comparing them to the clearly documented
> performance counters. However, in production code I'd use the NT internal APIs
> directly as they are many many orders of magnitude faster than the performance
> counters. (On my machine I could saturate a CPU querying the performance
> counters 1K times per second, where the internal APIs could be hit millions of
> times per second.)
> 
> If we're interested in compressed memory pages there are also ways to
"estimate"
> this by tracking the working set size of a particular system process. Ping me
> directly for more info.

Thank you Chris for the detailed information. That's really helpful.

I glanced over startup_metrics_utils.cc and web sites which are linked from
comments in the file. I don't fully understand internal NT APIs and performance
counter APIs yet but I'll try to follow your suggestion, i.e. using performance
counter APIs to figure out which stats we should track then find corresponding
internal ones.

Powered by Google App Engine
This is Rietveld 408576698