RESOLVED FIXED194594
[PSON] Introduce a WebContent Process cache
https://bugs.webkit.org/show_bug.cgi?id=194594
Summary [PSON] Introduce a WebContent Process cache
Chris Dumez
Reported 2019-02-13 08:53:42 PST
Introduce a WebContent Process cache to avoid launching new processes too frequently and reduce the power impact of PSON.
Attachments
Patch (106.35 KB, patch)
2019-02-13 16:02 PST, Chris Dumez
no flags
Patch (106.38 KB, patch)
2019-02-13 16:06 PST, Chris Dumez
no flags
Patch (106.55 KB, patch)
2019-02-13 19:49 PST, Chris Dumez
no flags
Patch (108.70 KB, patch)
2019-02-14 09:04 PST, Chris Dumez
no flags
Patch (109.25 KB, patch)
2019-02-14 09:24 PST, Chris Dumez
no flags
Chris Dumez
Comment 1 2019-02-13 08:54:11 PST
Chris Dumez
Comment 2 2019-02-13 16:02:23 PST
Chris Dumez
Comment 3 2019-02-13 16:06:16 PST
Chris Dumez
Comment 4 2019-02-13 19:49:23 PST
Geoffrey Garen
Comment 5 2019-02-13 21:35:21 PST
Comment on attachment 361986 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=361986&action=review r=me > Source/WebKit/UIProcess/WebProcessCache.cpp:121 > +void WebProcessCache::setApplicationIsActive(bool value) value => isActive > Source/WebKit/UIProcess/WebProcessCache.h:48 > + unsigned maximumSize() { return m_maximumSize; } We usually call this capacity. > Source/WebKit/UIProcess/WebProcessPool.cpp:1337 > void WebProcessPool::handleMemoryPressureWarning(Critical) > { > + RELEASE_LOG(PerformanceLogging, "%p - WebProcessPool::handleMemoryPressureWarning", this); > + > + m_webProcessCache->clear(); Does the process suspension code run the low memory warning in the web process? Relatedly, maybe the web process should listen to the low memory warning, in case it gets the warning before the UI process does. > Source/WebKit/UIProcess/WebProcessPool.cpp:2301 > + // FIXME: If the SuspendedPage is for this page, then we need to destroy the suspended page as we do not support having > + // multiple WebPages with the same ID in a given WebProcess currently (https://bugs.webkit.org/show_bug.cgi?id=191166). > + if (&(*it)->page() == &page) > + m_suspendedPages.remove(it); > Do we need the same check when we retrieve a process from the web process cache?
Chris Dumez
Comment 6 2019-02-14 06:33:26 PST
Comment on attachment 361986 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=361986&action=review >> Source/WebKit/UIProcess/WebProcessPool.cpp:1337 >> + m_webProcessCache->clear(); > > Does the process suspension code run the low memory warning in the web process? > > Relatedly, maybe the web process should listen to the low memory warning, in case it gets the warning before the UI process does. The processes suspension code does simulate a memory warning in the WebProcress on iOS. There is no process suspension on macOS and this cache will be macOS only I believe. It is a good point that the WebProcess’s memory pressure handler should likely cause the process the exit if it is in the cache. I will look into this. >> Source/WebKit/UIProcess/WebProcessPool.cpp:2301 >> > > Do we need the same check when we retrieve a process from the web process cache? No, processes in the cache cannot have any pages or suspended pages, they only enter the cache when they are about to exit because they are no longer used for anything.
Geoffrey Garen
Comment 7 2019-02-14 07:44:57 PST
Yeah, I think the cache should be mac only.
Chris Dumez
Comment 8 2019-02-14 07:53:34 PST
Comment on attachment 361986 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=361986&action=review >> Source/WebKit/UIProcess/WebProcessCache.cpp:121 >> +void WebProcessCache::setApplicationIsActive(bool value) > > value => isActive Ok >> Source/WebKit/UIProcess/WebProcessCache.h:48 >> + unsigned maximumSize() { return m_maximumSize; } > > We usually call this capacity. Ok but for the record I prefer maximumSize because I feel it is clearer. Vector has the concept of capacity and it has nothing to do with maximum size. >>> Source/WebKit/UIProcess/WebProcessPool.cpp:1337 >>> + m_webProcessCache->clear(); >> >> Does the process suspension code run the low memory warning in the web process? >> >> Relatedly, maybe the web process should listen to the low memory warning, in case it gets the warning before the UI process does. > > The processes suspension code does simulate a memory warning in the WebProcress on iOS. There is no process suspension on macOS and this cache will be macOS only I believe. > > It is a good point that the WebProcess’s memory pressure handler should likely cause the process the exit if it is in the cache. I will look into this. Note that we could simulate a memory pressure warning when entering the cache to try and slim the process as much as possible. However, doing so could impact performance as some valuable caches would be gone when trying to reuse the process. This could impact power and PLT. For this reason, I have not implemented it in this patch.
Chris Dumez
Comment 9 2019-02-14 09:04:20 PST
Brady Eidson
Comment 10 2019-02-14 09:21:35 PST
Comment on attachment 362022 [details] Patch 👍
Chris Dumez
Comment 11 2019-02-14 09:22:00 PST
(In reply to Brady Eidson from comment #10) > Comment on attachment 362022 [details] > Patch > > 👍 Thanks for looking as well.
Chris Dumez
Comment 12 2019-02-14 09:22:25 PST
I will try and figure out why the GTK bot is unhappy now :/
Chris Dumez
Comment 13 2019-02-14 09:24:19 PST
WebKit Commit Bot
Comment 14 2019-02-14 11:06:18 PST
Comment on attachment 362026 [details] Patch Clearing flags on attachment: 362026 Committed r241556: <https://trac.webkit.org/changeset/241556>
WebKit Commit Bot
Comment 15 2019-02-14 11:06:20 PST
All reviewed patches have been landed. Closing bug.
Geoffrey Garen
Comment 16 2019-02-14 11:16:47 PST
Probably the right move is to land without the pressure warning when entering the cache, and then separately a/b test a change to add a pressure warning. It’s a good point that a cache’s capacity limits its size, whereas a vector’s capacity does not. One thing that was unclear to me about “maximum size” was that I first read it as “the maximum size I have ever been” rather than “the maximum size I am allowed to reach”. STL vectors have a max size — but that means the max size that any vector could be, and it’s not adjustable for a given vector. I do think people often refer to caches as having a capacity. e.g. http://kb.mozillazine.org/Browser.cache.memory.capacity. I’ve gotten used to size as “how many elements I have” and capacity as “how many elements I could have before triggering some action (grow, evict, ring buffer, crash, whatever)”. Maybe we should circulate with other folks and see what the communal preference is.
Note You need to log in before you can comment on or make changes to this bug.