Changeset 208607 in webkit


Ignore:
Timestamp:
Nov 11, 2016, 1:50:11 PM (9 years ago)
Author:
Keith Rollin
Message:

Reduce number of platformMemoryUsage calls
https://bugs.webkit.org/show_bug.cgi?id=164375

Reviewed by Andreas Kling.

platformMemoryUsage was being called all the time while logging the
results of various memory-purging operations. This logging is
subordinate to the needs of performance and so can be removed.
Behavior is now as follows:

  • If memory-pressure relief logging is enabled, logging includes

memory usage information. On Cocoa, this logging is disabled by
default but can be enabled by setting LogMemoryJetsamDetails in
defaults.

  • Otherwise, if release-logging is enabled (as it is on Cocoa),

abbreviated memory pressure relief logging is performed: the logging
lines are printed but without any memory usage information.

  • Otherwise, no logging is performed.

No new tests -- no tests for logging.

  • platform/MemoryPressureHandler.cpp:

(WebCore::MemoryPressureHandler::ReliefLogger::logMemoryUsageChange):

  • platform/MemoryPressureHandler.h:

(WebCore::MemoryPressureHandler::ReliefLogger::ReliefLogger):
(WebCore::MemoryPressureHandler::ReliefLogger::~ReliefLogger):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r208606 r208607  
     12016-11-11  Keith Rollin  <krollin@apple.com>
     2
     3        Reduce number of platformMemoryUsage calls
     4        https://bugs.webkit.org/show_bug.cgi?id=164375
     5
     6        Reviewed by Andreas Kling.
     7
     8        platformMemoryUsage was being called all the time while logging the
     9        results of various memory-purging operations. This logging is
     10        subordinate to the needs of performance and so can be removed.
     11        Behavior is now as follows:
     12
     13        - If memory-pressure relief logging is enabled, logging includes
     14        memory usage information. On Cocoa, this logging is disabled by
     15        default but can be enabled by setting LogMemoryJetsamDetails in
     16        `defaults`.
     17        - Otherwise, if release-logging is enabled (as it is on Cocoa),
     18        abbreviated memory pressure relief logging is performed: the logging
     19        lines are printed but without any memory usage information.
     20        - Otherwise, no logging is performed.
     21
     22        No new tests -- no tests for logging.
     23
     24        * platform/MemoryPressureHandler.cpp:
     25        (WebCore::MemoryPressureHandler::ReliefLogger::logMemoryUsageChange):
     26        * platform/MemoryPressureHandler.h:
     27        (WebCore::MemoryPressureHandler::ReliefLogger::ReliefLogger):
     28        (WebCore::MemoryPressureHandler::ReliefLogger::~ReliefLogger):
     29
    1302016-11-11  Eric Carlson  <eric.carlson@apple.com>
    231
  • trunk/Source/WebCore/platform/MemoryPressureHandler.cpp

    r208534 r208607  
    7676#endif
    7777
    78     size_t currentMemory = platformMemoryUsage();
    79     if (currentMemory == static_cast<size_t>(-1) || m_initialMemory == static_cast<size_t>(-1)) {
    80         MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": (Unable to get dirty memory information for process)", m_logString);
    81         return;
     78    if (s_loggingEnabled) {
     79        size_t currentMemory = platformMemoryUsage();
     80        if (currentMemory == static_cast<size_t>(-1) || m_initialMemory == static_cast<size_t>(-1)) {
     81            MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": (Unable to get dirty memory information for process)", m_logString);
     82            return;
     83        }
     84
     85        long memoryDiff = currentMemory - m_initialMemory;
     86        if (memoryDiff < 0)
     87            MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": -dirty %ld bytes (from %zu to %zu)", m_logString, (memoryDiff * -1), m_initialMemory, currentMemory);
     88        else if (memoryDiff > 0)
     89            MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": +dirty %ld bytes (from %zu to %zu)", m_logString, memoryDiff, m_initialMemory, currentMemory);
     90        else
     91            MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": =dirty (at %zu bytes)", m_logString, currentMemory);
     92#if !RELEASE_LOG_DISABLED
     93    } else {
     94        MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION, m_logString);
     95#endif
    8296    }
    83 
    84     long memoryDiff = currentMemory - m_initialMemory;
    85     if (memoryDiff < 0)
    86         MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": -dirty %ld bytes (from %zu to %zu)", m_logString, (memoryDiff * -1), m_initialMemory, currentMemory);
    87     else if (memoryDiff > 0)
    88         MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": +dirty %ld bytes (from %zu to %zu)", m_logString, memoryDiff, m_initialMemory, currentMemory);
    89     else
    90         MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": =dirty (at %zu bytes)", m_logString, currentMemory);
    9197}
    9298
  • trunk/Source/WebCore/platform/MemoryPressureHandler.h

    r208534 r208607  
    9292        explicit ReliefLogger(const char *log)
    9393            : m_logString(log)
    94 #if !RELEASE_LOG_DISABLED
    95             , m_initialMemory(platformMemoryUsage())
    96 #else
    9794            , m_initialMemory(s_loggingEnabled ? platformMemoryUsage() : 0)
    98 #endif
    9995        {
    10096        }
     
    10298        ~ReliefLogger()
    10399        {
    104 #if !RELEASE_LOG_DISABLED
    105100            logMemoryUsageChange();
    106 #else
    107             if (s_loggingEnabled)
    108                 logMemoryUsageChange();
    109 #endif
    110101        }
    111102
Note: See TracChangeset for help on using the changeset viewer.