Bug 208468 - Clear CGColor cache on memory pressure
Summary: Clear CGColor cache on memory pressure
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-03-02 13:39 PST by Chris Dumez
Modified: 2020-03-23 16:31 PDT (History)
7 users (show)

See Also:


Attachments
Patch (4.24 KB, patch)
2020-03-02 13:40 PST, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2020-03-02 13:39:10 PST
Clear CGColor cache on memory pressure.
Comment 1 Chris Dumez 2020-03-02 13:40:43 PST
Created attachment 392182 [details]
Patch
Comment 2 Simon Fraser (smfr) 2020-03-02 13:45:48 PST
How much of it do we just fill up again when we paint?

I think this blanket "clear cache on memory pressure" will often just dirty more pages than we save.
Comment 3 Chris Dumez 2020-03-02 15:59:22 PST
Comment on attachment 392182 [details]
Patch

Will gather some data as this appears to be controversial.
Comment 4 Darin Adler 2020-03-23 16:11:39 PDT
Comment on attachment 392182 [details]
Patch

There’s an NSColor one just like this. Should we be clearing it too?
Comment 5 Darin Adler 2020-03-23 16:12:02 PDT
If we decide to clear either.
Comment 6 Simon Fraser (smfr) 2020-03-23 16:22:08 PDT
I just found SubimageCacheWithTimer, which isn't cleared at all on a memory warning (bug 207957).

I still think our cache management needs to be more centralized.
Comment 7 Darin Adler 2020-03-23 16:22:52 PDT
(In reply to Simon Fraser (smfr) from comment #6)
> I still think our cache management needs to be more centralized.

Sounds good! But what does it mean?
Comment 8 Simon Fraser (smfr) 2020-03-23 16:31:04 PDT
Off the cuff:
* every cache derives from a common base class, registers itself with a cache controller. This would make it harder for people to forget to handle new caches on memory pressure.
* cache controller decides how to reduce in size or clear caches based on memory pressure. Maybe caches have some knobs that describe their time/memory trade-offs

More general goals:
* if clearing caches involves mapping in more memory pages than would be saved, then don't do it (probably requires empirical measurement)
* rewrite caches to make it easier to dump memory pages without touching them