Title: [208607] trunk/Source/WebCore
Revision
208607
Author
[email protected]
Date
2016-11-11 13:50:11 -0800 (Fri, 11 Nov 2016)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (208606 => 208607)


--- trunk/Source/WebCore/ChangeLog	2016-11-11 21:45:21 UTC (rev 208606)
+++ trunk/Source/WebCore/ChangeLog	2016-11-11 21:50:11 UTC (rev 208607)
@@ -1,3 +1,32 @@
+2016-11-11  Keith Rollin  <[email protected]>
+
+        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):
+
 2016-11-11  Eric Carlson  <[email protected]>
 
         [MediaStream] defer resolution of getUserMedia promise made in a background tab

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (208606 => 208607)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2016-11-11 21:45:21 UTC (rev 208606)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2016-11-11 21:50:11 UTC (rev 208607)
@@ -75,19 +75,25 @@
 #define MEMORYPRESSURE_LOG(...) WTFLogAlways(__VA_ARGS__)
 #endif
 
-    size_t currentMemory = platformMemoryUsage();
-    if (currentMemory == static_cast<size_t>(-1) || m_initialMemory == static_cast<size_t>(-1)) {
-        MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": (Unable to get dirty memory information for process)", m_logString);
-        return;
+    if (s_loggingEnabled) {
+        size_t currentMemory = platformMemoryUsage();
+        if (currentMemory == static_cast<size_t>(-1) || m_initialMemory == static_cast<size_t>(-1)) {
+            MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": (Unable to get dirty memory information for process)", m_logString);
+            return;
+        }
+
+        long memoryDiff = currentMemory - m_initialMemory;
+        if (memoryDiff < 0)
+            MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": -dirty %ld bytes (from %zu to %zu)", m_logString, (memoryDiff * -1), m_initialMemory, currentMemory);
+        else if (memoryDiff > 0)
+            MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": +dirty %ld bytes (from %zu to %zu)", m_logString, memoryDiff, m_initialMemory, currentMemory);
+        else
+            MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": =dirty (at %zu bytes)", m_logString, currentMemory);
+#if !RELEASE_LOG_DISABLED
+    } else {
+        MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION, m_logString);
+#endif
     }
-
-    long memoryDiff = currentMemory - m_initialMemory;
-    if (memoryDiff < 0)
-        MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": -dirty %ld bytes (from %zu to %zu)", m_logString, (memoryDiff * -1), m_initialMemory, currentMemory);
-    else if (memoryDiff > 0)
-        MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": +dirty %ld bytes (from %zu to %zu)", m_logString, memoryDiff, m_initialMemory, currentMemory);
-    else
-        MEMORYPRESSURE_LOG("Memory pressure relief: " STRING_SPECIFICATION ": =dirty (at %zu bytes)", m_logString, currentMemory);
 }
 
 #if !PLATFORM(COCOA) && !OS(LINUX) && !PLATFORM(WIN)

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (208606 => 208607)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.h	2016-11-11 21:45:21 UTC (rev 208606)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h	2016-11-11 21:50:11 UTC (rev 208607)
@@ -91,22 +91,13 @@
     public:
         explicit ReliefLogger(const char *log)
             : m_logString(log)
-#if !RELEASE_LOG_DISABLED
-            , m_initialMemory(platformMemoryUsage())
-#else
             , m_initialMemory(s_loggingEnabled ? platformMemoryUsage() : 0)
-#endif
         {
         }
 
         ~ReliefLogger()
         {
-#if !RELEASE_LOG_DISABLED
             logMemoryUsageChange();
-#else
-            if (s_loggingEnabled)
-                logMemoryUsageChange();
-#endif
         }
 
         const char* logString() const { return m_logString; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to