Changeset 208538 in webkit


Ignore:
Timestamp:
Nov 10, 2016 8:03:51 AM (7 years ago)
Author:
Carlos Garcia Campos
Message:

[Linux] Memory process values shown by the WebMemorySampler in linux are wrong
https://bugs.webkit.org/show_bug.cgi?id=164591

Reviewed by Michael Catanzaro.

It's parsing /proc/self/statm, and returning the values as if they were bytes, but they are number of pages, so
to get the bytes we need to take the page size into account. In r208534 I added a method to get /proc/self/statm
values in bytes to Platform layer, so we can simply use that instead.

  • Shared/linux/WebMemorySamplerLinux.cpp:

(WebKit::WebMemorySampler::sampleWebKit): Use currentProcessMemoryStatus() and update the descriptions to
clarify that values are in bytes.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r208534 r208538  
     12016-11-10  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [Linux] Memory process values shown by the WebMemorySampler in linux are wrong
     4        https://bugs.webkit.org/show_bug.cgi?id=164591
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        It's parsing /proc/self/statm, and returning the values as if they were bytes, but they are number of pages, so
     9        to get the bytes we need to take the page size into account. In r208534 I added a method to get /proc/self/statm
     10        values in bytes to Platform layer, so we can simply use that instead.
     11
     12        * Shared/linux/WebMemorySamplerLinux.cpp:
     13        (WebKit::WebMemorySampler::sampleWebKit): Use currentProcessMemoryStatus() and update the descriptions to
     14        clarify that values are in bytes.
     15
    1162016-10-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    217
  • trunk/Source/WebKit2/Shared/linux/WebMemorySamplerLinux.cpp

    r198527 r208538  
    2929#if ENABLE(MEMORY_SAMPLER)
    3030
    31 #include "NotImplemented.h"
    3231#include <JavaScriptCore/MemoryStatistics.h>
     32#include <WebCore/CurrentProcessMemoryStatus.h>
     33#include <WebCore/JSDOMWindow.h>
     34#include <WebCore/NotImplemented.h>
    3335#include <runtime/JSCInlines.h>
    34 #include <WebCore/JSDOMWindow.h>
    3536#include <runtime/JSLock.h>
    3637#include <string.h>
     
    4445
    4546namespace WebKit {
    46 
    47 struct ApplicationMemoryStats {
    48     size_t totalProgramSize;
    49     size_t residentSetSize;
    50     size_t sharedSize;
    51     size_t textSize;
    52     size_t librarySize;
    53     size_t dataStackSize;
    54     size_t dirtyPageSize;
    55 };
    5647
    5748static const unsigned int maxBuffer = 128;
     
    8576}
    8677
    87 static ApplicationMemoryStats sampleMemoryAllocatedForApplication()
    88 {
    89     ApplicationMemoryStats applicationStats = {0, 0, 0, 0, 0, 0, 0};
    90     char processPath[maxProcessPath];
    91     snprintf(processPath, maxProcessPath, "/proc/self/statm");
    92     FILE* statmFileDescriptor = fopen(processPath, "r");
    93     if (!statmFileDescriptor)
    94         return applicationStats;
    95 
    96     applicationStats.totalProgramSize = nextToken(statmFileDescriptor).toInt();
    97     applicationStats.residentSetSize = nextToken(statmFileDescriptor).toInt();
    98     applicationStats.sharedSize = nextToken(statmFileDescriptor).toInt();
    99     applicationStats.textSize = nextToken(statmFileDescriptor).toInt();
    100     applicationStats.librarySize = nextToken(statmFileDescriptor).toInt();
    101     applicationStats.dataStackSize = nextToken(statmFileDescriptor).toInt();
    102     applicationStats.dirtyPageSize = nextToken(statmFileDescriptor).toInt();
    103 
    104     fclose(statmFileDescriptor);
    105 
    106     return applicationStats;
    107 }
    108 
    10978String WebMemorySampler::processName() const
    11079{
     
    131100    appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Timestamp"), now);
    132101
    133     ApplicationMemoryStats applicationStats = sampleMemoryAllocatedForApplication();
     102    ProcessMemoryStatus processMemoryStatus;
     103    currentProcessMemoryStatus(processMemoryStatus);
    134104
    135     appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Total Program Size"), applicationStats.totalProgramSize);
    136     appendKeyValuePair(webKitMemoryStats, ASCIILiteral("RSS"), applicationStats.residentSetSize);
    137     appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Shared"), applicationStats.sharedSize);
    138     appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Text"), applicationStats.textSize);
    139     appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Library"), applicationStats.librarySize);
    140     appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Data/Stack"), applicationStats.dataStackSize);
    141     appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Dirty"), applicationStats.dirtyPageSize);
     105    appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Total Program Bytes"), processMemoryStatus.size);
     106    appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Resident Set Bytes"), processMemoryStatus.resident);
     107    appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Resident Shared Bytes"), processMemoryStatus.shared);
     108    appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Text Bytes"), processMemoryStatus.text);
     109    appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Library Bytes"), processMemoryStatus.lib);
     110    appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Data + Stack Bytes"), processMemoryStatus.data);
     111    appendKeyValuePair(webKitMemoryStats, ASCIILiteral("Dirty Bytes"), processMemoryStatus.dt);
    142112
    143113    size_t totalBytesInUse = 0;
Note: See TracChangeset for help on using the changeset viewer.