WebKit Bugzilla
Attachment 346465 Details for
Bug 188299
: Web process never leaves memory pressured state if caused by process size limit
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
process-limit-notifications.patch (text/plain), 5.33 KB, created by
Antti Koivisto
on 2018-08-03 02:29:57 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Antti Koivisto
Created:
2018-08-03 02:29:57 PDT
Size:
5.33 KB
patch
obsolete
>Index: Source/WTF/ChangeLog >=================================================================== >--- Source/WTF/ChangeLog (revision 234539) >+++ Source/WTF/ChangeLog (working copy) >@@ -1,3 +1,25 @@ >+2018-08-03 Antti Koivisto <antti@apple.com> >+ >+ Web process never leaves memory pressured state if caused by per-process limit >+ https://bugs.webkit.org/show_bug.cgi?id=188299 >+ <rdar://problem/42157442> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ For system memory pressure warnings we get signaled when exiting the state so we can clear >+ the isUnderMemoryPressure bit. However as a compatibility behavior we were also notified using >+ the same notifications when approaching the per-process limit. In this case there is no "all clear" >+ notification so we'd stay in pressured state forever, leading to unnecessarily degraded user experience. >+ >+ * wtf/cocoa/MemoryPressureHandlerCocoa.mm: >+ (WTF::MemoryPressureHandler::install): >+ >+ Install a handler for per-process notifications. This disables the compatibility behavior, >+ vm pressure notifications will be received for vm pressure only. >+ >+ Per-process notifications are treated as one-shot things. We do cleanups based on criticality but >+ don't enter the pressured state. >+ > 2018-08-02 Saam Barati <sbarati@apple.com> > > Reading instructionPointer from PlatformRegisters may fail when using pointer tagging >Index: Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm >=================================================================== >--- Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm (revision 234496) >+++ Source/WTF/wtf/cocoa/MemoryPressureHandlerCocoa.mm (working copy) >@@ -31,6 +31,10 @@ > #import <malloc/malloc.h> > #import <notify.h> > >+#if USE(APPLE_INTERNAL_SDK) >+#include <dispatch/private.h> >+#endif >+ > #define ENABLE_FMW_FOOTPRINT_COMPARISON 0 > > extern "C" void cache_simulate_memory_warning_event(uint64_t); >@@ -68,30 +72,52 @@ void MemoryPressureHandler::install() > > dispatch_async(dispatch_get_main_queue(), ^{ > #if PLATFORM(IOS) >- _cache_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_NORMAL | DISPATCH_MEMORYPRESSURE_WARN | DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue()); >-#elif PLATFORM(MAC) >- _cache_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue()); >+ auto memoryStatusFlags = DISPATCH_MEMORYPRESSURE_NORMAL | DISPATCH_MEMORYPRESSURE_WARN | DISPATCH_MEMORYPRESSURE_CRITICAL; >+#if USE(APPLE_INTERNAL_SDK) >+ memoryStatusFlags |= DISPATCH_MEMORYPRESSURE_PROC_LIMIT_WARN | DISPATCH_MEMORYPRESSURE_PROC_LIMIT_CRITICAL; >+#endif >+#else // PLATFORM(MAC) >+ auto memoryStatusFlags = DISPATCH_MEMORYPRESSURE_CRITICAL; >+ auto isCritical = true; > #endif >+ _cache_event_source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, memoryStatusFlags, dispatch_get_main_queue()); > > dispatch_set_context(_cache_event_source, this); > dispatch_source_set_event_handler(_cache_event_source, ^{ >- bool critical = true; > #if PLATFORM(IOS) > unsigned long status = dispatch_source_get_data(_cache_event_source); >- critical = status == DISPATCH_MEMORYPRESSURE_CRITICAL; >- auto& memoryPressureHandler = MemoryPressureHandler::singleton(); >- bool wasCritical = memoryPressureHandler.isUnderMemoryPressure(); >- memoryPressureHandler.setUnderMemoryPressure(critical); >+ >+ // Per process notification are one shot things while the system status is a state. >+ bool isUnderVMMemoryPressure = [&] { >+ if (status == DISPATCH_MEMORYPRESSURE_CRITICAL) >+ return true; >+ if (status == DISPATCH_MEMORYPRESSURE_NORMAL) >+ return false; >+ return MemoryPressureHandler::singleton().isUnderMemoryPressure(); >+ }(); >+ >+ bool isCritical = [&] { >+ if (status == DISPATCH_MEMORYPRESSURE_CRITICAL) >+ return true; >+#if USE(APPLE_INTERNAL_SDK) >+ if (status == DISPATCH_MEMORYPRESSURE_PROC_LIMIT_CRITICAL) >+ return true; >+#endif >+ return false; >+ }(); >+ >+ MemoryPressureHandler::singleton().setUnderMemoryPressure(isUnderVMMemoryPressure); >+ > if (status == DISPATCH_MEMORYPRESSURE_NORMAL) { > if (ReliefLogger::loggingEnabled()) >- NSLog(@"System is no longer under (%s) memory pressure.", wasCritical ? "critical" : "non-critical"); >+ NSLog(@"System is no longer under memory pressure."); > return; > } > > if (ReliefLogger::loggingEnabled()) >- NSLog(@"Got memory pressure notification (%s)", critical ? "critical" : "non-critical"); >+ NSLog(@"Got memory pressure notification %lu (%s)", status, isCritical ? "critical" : "non-critical"); > #endif >- MemoryPressureHandler::singleton().respondToMemoryPressure(critical ? Critical::Yes : Critical::No); >+ MemoryPressureHandler::singleton().respondToMemoryPressure(isCritical ? Critical::Yes : Critical::No); > }); > dispatch_resume(_cache_event_source); > });
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188299
:
346465
|
346470
|
346599
|
346625