New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 707022 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Last visit > 30 days ago
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows , Mac
Pri: 1
Type: Bug
Hotlist-MemoryInfra



Sign in to add a comment

Implement fast and slow computations for Private Memory Footprint on Windows.

Project Member Reported by erikc...@chromium.org, Mar 30 2017

Issue description

Fast computation uses private resident + compressed/swapped.
Slow computation walks all memory regions to collect detailed stats.
 
 

Comment 2 by ajwong@chromium.org, May 22 2017

Owner: ajwong@chromium.org
Lots of research was done.

This is the working doc for the experiments and writeup:

https://docs.google.com/document/d/1q99AeDUL28o2e8BGr15K3lG2IvBrnEafUr71q0lqUvg/edit#

Basically, it looks like PROCESS_MEMORY_COUNTERS_EX::PrivateUsage is the right counter for the fast computation.

The summary is, Windows has a concept of "Commit Charge." The Kernel's memory subsystem, accessed via VirtualAlloc()/VirtualFree() "commits" memory by guaranteeing it can be backed with the pagefile. Thus, the amount of _private_ committed memory is equal to the amount of uncompressed bytes in ram and reserved/written to swap.

This does NOT count LargePages and AWE Pages which may be used indirectly via third-party libraries or drives (esp the GPU). However, as a first pass, this is pretty close.

The other quirk is this definition of committed memory specifically means the counter is unaffected by calls to VirtualAlloc(MEM_RESET) and DisardVirtualMemory(). This means that discarding memory via PartitionAlloc's discarding APIs will NOT change this counter.  Memory discarded via these APIs are just optimizations for when/if I/O to the pagefile occurs. They do NOT reduce the private memory footprint as the OS still keeps something reserved in the pagefile.


For the slow computation, walking the whole VM space with VirtualQueryEx and QueryWorkingSetEx can yield us accurate numbers, but it requires O(n) syscalls where N = number of VM segments we have in memory.

Comment 3 by ajwong@chromium.org, May 22 2017

Cc: erikc...@chromium.org
Project Member

Comment 4 by bugdroid1@chromium.org, May 25 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4cbb56a450d7a54b6b1bc95cdf6474cc9ef5697f

commit 4cbb56a450d7a54b6b1bc95cdf6474cc9ef5697f
Author: Albert J. Wong <ajwong@chromium.org>
Date: Thu May 25 19:20:52 2017

Add in PlatformPrivateMemoryFootprint for Windows.

In Windows, the PrivateMemoryFootprint (physical ram and swap space
allocated to your procesS) ends up being roughly the commit charge which
is already calcualted by ProcessMetrics::GetMemoryBytes().

Note, this counter does NOT map obviously to what you might think.
See the bug for details.

BUG=707022

Change-Id: I5318eaa3aaa66269e680e373eb9669cb01a5d701
Reviewed-on: https://chromium-review.googlesource.com/513146
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Fadi Meawad <fmeawad@chromium.org>
Reviewed-by: Erik Chen <erikchen@chromium.org>
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Cr-Commit-Position: refs/heads/master@{#474747}
[modify] https://crrev.com/4cbb56a450d7a54b6b1bc95cdf6474cc9ef5697f/base/trace_event/process_memory_totals.h
[modify] https://crrev.com/4cbb56a450d7a54b6b1bc95cdf6474cc9ef5697f/components/tracing/common/process_metrics_memory_dump_provider.cc
[modify] https://crrev.com/4cbb56a450d7a54b6b1bc95cdf6474cc9ef5697f/services/resource_coordinator/memory_instrumentation/coordinator_impl.cc
[modify] https://crrev.com/4cbb56a450d7a54b6b1bc95cdf6474cc9ef5697f/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation_struct_traits.cc
[modify] https://crrev.com/4cbb56a450d7a54b6b1bc95cdf6474cc9ef5697f/services/resource_coordinator/public/cpp/memory_instrumentation/memory_instrumentation_struct_traits.h
[modify] https://crrev.com/4cbb56a450d7a54b6b1bc95cdf6474cc9ef5697f/services/resource_coordinator/public/interfaces/memory_instrumentation/memory_instrumentation.mojom

Project Member

Comment 5 by bugdroid1@chromium.org, Jun 1 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/1564e791a8a6678d9c550bf4acb78500a4c19d05

commit 1564e791a8a6678d9c550bf4acb78500a4c19d05
Author: erikchen <erikchen@chromium.org>
Date: Thu Jun 01 10:05:11 2017

memory-infra: Fix a unit conversion error for private memory footprint.

Bytes were being converted to kilobytes without a division.

BUG=707022

Review-Url: https://codereview.chromium.org/2914903002
Cr-Commit-Position: refs/heads/master@{#476241}

[modify] https://crrev.com/1564e791a8a6678d9c550bf4acb78500a4c19d05/services/resource_coordinator/memory_instrumentation/coordinator_impl.cc

Sign in to add a comment