Prune more resources from the MemoryCache before process suspension or on simulated memory warning by doing a synchronous JS garbage collection and sweep *before* pruning dead resources from the memory cache. Previously, we would do the garbage collection after pruning the MemoryCache which meant that a lot of resources became dead after we tried to prune them. At the end a basic browsing on apple.com, we are able to remove ~17% more resources from the MemoryCache on simulated memory warning with this change. Pruning as much as we can from the memory cache on critical memory pressure or before process suspension is not only useful to free up memory but also to make room in the vnode table as a lot of CachedResources are mmmap'd from the network disk cache.
Created attachment 254246 [details] Patch
Created attachment 254247 [details] Patch
Created attachment 254249 [details] Patch
Created attachment 254251 [details] Patch
Created attachment 254253 [details] Patch
Ah, green bubbles :)
Created attachment 254267 [details] Patch
Comment on attachment 254267 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=254267&action=review r=me this is great. > Source/WebCore/platform/MemoryPressureHandler.cpp:148 > + // Do a full sweep of collected objects. Sidenote (not really about this patch): If we take the garbageCollectNow() path above, it will do a full sweep before returning. If we take the garbageCollectSoon() path, it won't generate any new garbage to sweep, since it only accelerates the next collection, but will never actually perform it. What will happen here is that if we recently did a collection that generated work for the IncrementalSweeper and that work is not yet finished, it will synchronously finish now. I think it's a good thing to be doing here, just wanted to clarify what's really going on.
(In reply to comment #8) > Comment on attachment 254267 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=254267&action=review > > r=me this is great. > > > Source/WebCore/platform/MemoryPressureHandler.cpp:148 > > + // Do a full sweep of collected objects. > > Sidenote (not really about this patch): > > If we take the garbageCollectNow() path above, it will do a full sweep > before returning. I wasn't aware, I'll tweak the code accordingly before landing. > If we take the garbageCollectSoon() path, it won't generate any new garbage > to sweep, since it only accelerates the next collection, but will never > actually perform it. > What will happen here is that if we recently did a collection that generated > work for the IncrementalSweeper and that work is not yet finished, it will > synchronously finish now. > I think it's a good thing to be doing here, just wanted to clarify what's > really going on. It was my understanding that this still was useful. Ideally, we would pass a callback to garbageCollectSoon() so that we can do a sweep and prune dead resources from the memory cache once finished.
Created attachment 254270 [details] Patch
Comment on attachment 254270 [details] Patch Clearing flags on attachment: 254270 Committed r185206: <http://trac.webkit.org/changeset/185206>
All reviewed patches have been landed. Closing bug.