• erikchen's avatar
    Correct macOS private memory footprint calculations. · 7c1d03f5
    erikchen authored
    On macOS, measurements for private memory footprint overcount by
    faulted pages in anonymous shared memory. To discount for this, this CL touches
    all the resident pages in anonymous shared memory, thus making them
    faulted as well. This relies on two assumptions:
    
    1) Consumers use shared memory from front to back. Thus, if there are
    (N) resident pages, those pages represent the first N * PAGE_SIZE bytes in
    the shared memory region.
    
    2) The faulting logic is run shortly before the logic that calculates
    phys_footprint, thus ensuring that the discrepancy between faulted and
    resident pages is minimal.
    
    The performance penalty is expected to be small.
    
    * Most of the time, we expect the pages to already be resident and faulted,
    thus incurring a cache penalty read hit [since we read from each resident
    page].
    
    * Rarely, we expect the pages to be resident but not faulted, resulting in
    soft faults + cache penalty.
    
    * If assumption (1) is invalid, this will potentially fault some
    previously non-resident pages, thus increasing memory usage, without fixing
    the accounting.
    
    Bug: 812346
    Change-Id: I04e91bc09bf6bdf2f9179dd8d678c92425e98fed
    Reviewed-on: https://chromium-review.googlesource.com/973883Reviewed-by: default avatarPrimiano Tucci <primiano@chromium.org>
    Reviewed-by: default avatarAlbert J. Wong <ajwong@chromium.org>
    Commit-Queue: Erik Chen <erikchen@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#545086}
    7c1d03f5
process_memory_dump.cc 20 KB