Bug 220659

Summary: [GPUProcess] Improve the GPUProcess' memory pressure handler
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebKit2Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: ggaren, simon.fraser, thorton, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Chris Dumez 2021-01-15 08:52:56 PST
Improve the GPUProcess' memory pressure handler to clear things like the IOSurfacePool and the SubimageCacheWithTimer.
Comment 1 Chris Dumez 2021-01-15 08:54:35 PST
Created attachment 417703 [details]
Patch
Comment 2 Simon Fraser (smfr) 2021-01-15 09:37:44 PST
Comment on attachment 417703 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417703&action=review

Should we also propagate the memory warning to the web content processes? Or will they also get the warning?

> Source/WebCore/page/MemoryRelease.cpp:169
> +        // Return unused pages back to the OS now as this will likely give us a little memory to work with.

I don't think this comment adds anything. In fact, I'm confused by it.

> Source/WebCore/page/MemoryRelease.cpp:176
> +    if (synchronous == Synchronous::Yes)
> +        WTF::releaseFastMallocFreeMemory();

What's the reason for calling it a second time?
Comment 3 Chris Dumez 2021-01-15 09:41:25 PST
Comment on attachment 417703 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417703&action=review

>> Source/WebCore/page/MemoryRelease.cpp:169
>> +        // Return unused pages back to the OS now as this will likely give us a little memory to work with.
> 
> I don't think this comment adds anything. In fact, I'm confused by it.

Ok. This was from releaseMemory() above.

>> Source/WebCore/page/MemoryRelease.cpp:176
>> +        WTF::releaseFastMallocFreeMemory();
> 
> What's the reason for calling it a second time?

I am not sure. This is a stripped down version of releaseMemory() above.
Comment 4 Simon Fraser (smfr) 2021-01-15 09:46:17 PST
Comment on attachment 417703 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417703&action=review

>>> Source/WebCore/page/MemoryRelease.cpp:169
>>> +        // Return unused pages back to the OS now as this will likely give us a little memory to work with.
>> 
>> I don't think this comment adds anything. In fact, I'm confused by it.
> 
> Ok. This was from releaseMemory() above.

I need to read more closely. This is releasing "free" memory, so presumably pages that are free to return to the OS. The comments makes more sense now (but the comment should use "free", not "unused" to match the function name).

>>> Source/WebCore/page/MemoryRelease.cpp:176
>>> +        WTF::releaseFastMallocFreeMemory();
>> 
>> What's the reason for calling it a second time?
> 
> I am not sure. This is a stripped down version of releaseMemory() above.

I'm guessing this can touch pages and thus trigger them getting mapped back in.
Comment 5 Chris Dumez 2021-01-15 09:47:09 PST
Created attachment 417711 [details]
Patch
Comment 6 EWS 2021-01-15 10:29:13 PST
Committed r271526: <https://trac.webkit.org/changeset/271526>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 417711 [details].
Comment 7 Radar WebKit Bug Importer 2021-01-15 10:30:22 PST
<rdar://problem/73254115>