Title: [169236] trunk/Source
Revision
169236
Author
[email protected]
Date
2014-05-22 18:34:26 -0700 (Thu, 22 May 2014)

Log Message

Hook up a setting for showing detailed logging during memory pressure relief.
<https://webkit.org/b/133194>

Source/WebCore:
Make the pressure relief logger opt-in. Also make it flush memory back to the
OS (for both malloc and FastMalloc) to get more accurate numbers at each step.

Reviewed by Gavin Barraclough.

* WebCore.exp.in:
* platform/MemoryPressureHandler.cpp:
* platform/MemoryPressureHandler.h:
(WebCore::MemoryPressureHandler::ReliefLogger::ReliefLogger):
(WebCore::MemoryPressureHandler::ReliefLogger::~ReliefLogger):
(WebCore::MemoryPressureHandler::ReliefLogger::setLoggingEnabled):
* platform/cocoa/MemoryPressureHandlerCocoa.mm:
(WebCore::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):

Source/WebKit2:
Plumb through the same setting that we used for detailed logging in WK1.

Reviewed by Gavin Barraclough.

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::WebProcessCreationParameters):
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/mac/WebContextMac.mm:
(WebKit::WebContext::platformInitializeWebProcess):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (169235 => 169236)


--- trunk/Source/WebCore/ChangeLog	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebCore/ChangeLog	2014-05-23 01:34:26 UTC (rev 169236)
@@ -1,3 +1,22 @@
+2014-05-22  Andreas Kling  <[email protected]>
+
+        Hook up a setting for showing detailed logging during memory pressure relief.
+        <https://webkit.org/b/133194>
+
+        Make the pressure relief logger opt-in. Also make it flush memory back to the
+        OS (for both malloc and FastMalloc) to get more accurate numbers at each step.
+
+        Reviewed by Gavin Barraclough.
+
+        * WebCore.exp.in:
+        * platform/MemoryPressureHandler.cpp:
+        * platform/MemoryPressureHandler.h:
+        (WebCore::MemoryPressureHandler::ReliefLogger::ReliefLogger):
+        (WebCore::MemoryPressureHandler::ReliefLogger::~ReliefLogger):
+        (WebCore::MemoryPressureHandler::ReliefLogger::setLoggingEnabled):
+        * platform/cocoa/MemoryPressureHandlerCocoa.mm:
+        (WebCore::MemoryPressureHandler::ReliefLogger::platformMemoryUsage):
+
 2014-05-22  Brady Eidson  <[email protected]>
 
         Don't scan for phone numbers in editable regions

Modified: trunk/Source/WebCore/WebCore.exp.in (169235 => 169236)


--- trunk/Source/WebCore/WebCore.exp.in	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-05-23 01:34:26 UTC (rev 169236)
@@ -875,6 +875,7 @@
 __ZN7WebCore21BlobDataFileReferenceD2Ev
 __ZN7WebCore21CrossThreadCopierBaseILb0ELb0EN3WTF6StringEE4copyERKS2_
 __ZN7WebCore21CrossThreadCopierBaseILb0ELb0ENS_19IDBDatabaseMetadataEE4copyERKS1_
+__ZN7WebCore21MemoryPressureHandler12ReliefLogger16s_loggingEnabledE
 __ZN7WebCore21MemoryPressureHandler7installEv
 __ZN7WebCore21NetworkStorageSession21defaultStorageSessionEv
 __ZN7WebCore21NetworkStorageSession25switchToNewTestingSessionEv

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.cpp (169235 => 169236)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.cpp	2014-05-23 01:34:26 UTC (rev 169236)
@@ -45,6 +45,8 @@
 
 namespace WebCore {
 
+bool MemoryPressureHandler::ReliefLogger::s_loggingEnabled = false;
+
 MemoryPressureHandler& memoryPressureHandler()
 {
     DEPRECATED_DEFINE_STATIC_LOCAL(MemoryPressureHandler, staticMemoryPressureHandler, ());

Modified: trunk/Source/WebCore/platform/MemoryPressureHandler.h (169235 => 169236)


--- trunk/Source/WebCore/platform/MemoryPressureHandler.h	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebCore/platform/MemoryPressureHandler.h	2014-05-23 01:34:26 UTC (rev 169236)
@@ -74,16 +74,18 @@
     public:
         explicit ReliefLogger(const char *log)
             : m_logString(log)
-            , m_initialMemory(platformMemoryUsage())
+            , m_initialMemory(s_loggingEnabled ? platformMemoryUsage() : 0)
         {
         }
 
         ~ReliefLogger()
         {
-            platformLog();
+            if (s_loggingEnabled)
+                platformLog();
         }
 
         const char* logString() const { return m_logString; }
+        static void setLoggingEnabled(bool enabled) { s_loggingEnabled = enabled; }
 
     private:
         size_t platformMemoryUsage();
@@ -91,8 +93,10 @@
 
         const char* m_logString;
         size_t m_initialMemory;
-};
 
+        static bool s_loggingEnabled;
+    };
+
 private:
     void uninstall();
 

Modified: trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm (169235 => 169236)


--- trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebCore/platform/cocoa/MemoryPressureHandlerCocoa.mm	2014-05-23 01:34:26 UTC (rev 169236)
@@ -170,6 +170,11 @@
 #if PLATFORM(IOS) || (PLATFORM(MAC) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1090)
 size_t MemoryPressureHandler::ReliefLogger::platformMemoryUsage()
 {
+    // Flush free memory back to the OS before every measurement.
+    // Note that this code only runs when detailed pressure relief logging is enabled.
+    WTF::releaseFastMallocFreeMemory();
+    malloc_zone_pressure_relief(nullptr, 0);
+
     task_vm_info_data_t vmInfo;
     mach_msg_type_number_t count = TASK_VM_INFO_COUNT;
     kern_return_t err = task_info(mach_task_self(), TASK_VM_INFO, (task_info_t) &vmInfo, &count);

Modified: trunk/Source/WebKit2/ChangeLog (169235 => 169236)


--- trunk/Source/WebKit2/ChangeLog	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebKit2/ChangeLog	2014-05-23 01:34:26 UTC (rev 169236)
@@ -1,3 +1,22 @@
+2014-05-22  Andreas Kling  <[email protected]>
+
+        Hook up a setting for showing detailed logging during memory pressure relief.
+        <https://webkit.org/b/133194>
+
+        Plumb through the same setting that we used for detailed logging in WK1.
+
+        Reviewed by Gavin Barraclough.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::WebProcessCreationParameters):
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/mac/WebContextMac.mm:
+        (WebKit::WebContext::platformInitializeWebProcess):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2014-05-22  Andy Estes  <[email protected]>
 
         [iOS] Send shareable resources to QuickLook if enabled

Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp (169235 => 169236)


--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.cpp	2014-05-23 01:34:26 UTC (rev 169236)
@@ -42,6 +42,7 @@
     , shouldEnableKerningAndLigaturesByDefault(false)
     , shouldEnableJIT(false)
     , shouldEnableFTLJIT(false)
+    , shouldEnableMemoryPressureReliefLogging(false)
 #endif
 #if ENABLE(NETWORK_PROCESS)
     , usesNetworkProcess(false)
@@ -113,6 +114,7 @@
     encoder << shouldEnableKerningAndLigaturesByDefault;
     encoder << shouldEnableJIT;
     encoder << shouldEnableFTLJIT;
+    encoder << shouldEnableMemoryPressureReliefLogging;
     encoder << !!bundleParameterData;
     if (bundleParameterData)
         encoder << bundleParameterData->dataReference();
@@ -242,6 +244,8 @@
         return false;
     if (!decoder.decode(parameters.shouldEnableFTLJIT))
         return false;
+    if (!decoder.decode(parameters.shouldEnableMemoryPressureReliefLogging))
+        return false;
     
     bool hasBundleParameterData;
     if (!decoder.decode(hasBundleParameterData))

Modified: trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h (169235 => 169236)


--- trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebKit2/Shared/WebProcessCreationParameters.h	2014-05-23 01:34:26 UTC (rev 169236)
@@ -136,6 +136,7 @@
     bool shouldEnableKerningAndLigaturesByDefault;
     bool shouldEnableJIT;
     bool shouldEnableFTLJIT;
+    bool shouldEnableMemoryPressureReliefLogging;
     
     RefPtr<API::Data> bundleParameterData;
 

Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm (169235 => 169236)


--- trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMac.mm	2014-05-23 01:34:26 UTC (rev 169236)
@@ -186,6 +186,7 @@
     parameters.shouldEnableKerningAndLigaturesByDefault = [[NSUserDefaults standardUserDefaults] boolForKey:WebKitKerningAndLigaturesEnabledByDefaultDefaultsKey];
     parameters.shouldEnableJIT = [[NSUserDefaults standardUserDefaults] boolForKey:WebKitJSCJITEnabledDefaultsKey];
     parameters.shouldEnableFTLJIT = [[NSUserDefaults standardUserDefaults] boolForKey:WebKitJSCFTLJITEnabledDefaultsKey];
+    parameters.shouldEnableMemoryPressureReliefLogging = [[NSUserDefaults standardUserDefaults] boolForKey:@"LogMemoryJetsamDetails"];
     
 #if HAVE(HOSTED_CORE_ANIMATION)
 #if !PLATFORM(IOS)

Modified: trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm (169235 => 169236)


--- trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm	2014-05-23 01:29:30 UTC (rev 169235)
+++ trunk/Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm	2014-05-23 01:34:26 UTC (rev 169236)
@@ -42,6 +42,7 @@
 #import <WebCore/Font.h>
 #import <WebCore/LocalizedStrings.h>
 #import <WebCore/MemoryCache.h>
+#import <WebCore/MemoryPressureHandler.h>
 #import <WebCore/PageCache.h>
 #import <WebCore/WebCoreNSURLExtras.h>
 #import <WebKitSystemInterface.h>
@@ -191,6 +192,8 @@
     m_shouldForceScreenFontSubstitution = parameters.shouldForceScreenFontSubstitution;
     Font::setDefaultTypesettingFeatures(parameters.shouldEnableKerningAndLigaturesByDefault ? Kerning | Ligatures : 0);
 
+    MemoryPressureHandler::ReliefLogger::setLoggingEnabled(parameters.shouldEnableMemoryPressureReliefLogging);
+
     setEnhancedAccessibility(parameters.accessibilityEnhancedUserInterfaceEnabled);
 
 #if USE(APPKIT)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to