Bug 153851

Summary: [iOS] Throw away linked code when navigating to a new page.
Product: WebKit Reporter: Andreas Kling <kling>
Component: WebCore JavaScriptAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, cdumez, commit-queue, japhet, keith_miller, kling, mark.lam, msaboff, sbarati
Priority: P2 Keywords: Performance
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 153940    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch for relanding
none
Patch
none
Patch
koivisto: review+
Patch for landing none

Description Andreas Kling 2016-02-03 17:51:07 PST
We can keep our peak memory usage down by throwing away linked code when navigating to a new page.
Since linked code is tied to a specific global object, it won't be useful to the incoming page.
In the event of a backwards navigation, the cost of relinking that code is far lower than the memory cost of keeping it around.
Comment 1 Andreas Kling 2016-02-03 17:54:32 PST
Created attachment 270619 [details]
Patch
Comment 2 WebKit Commit Bot 2016-02-03 19:12:29 PST
Comment on attachment 270619 [details]
Patch

Clearing flags on attachment: 270619

Committed r196104: <http://trac.webkit.org/changeset/196104>
Comment 3 WebKit Commit Bot 2016-02-03 19:12:35 PST
All reviewed patches have been landed.  Closing bug.
Comment 4 WebKit Commit Bot 2016-02-06 02:08:29 PST
Re-opened since this is blocked by bug 153940
Comment 5 Andreas Kling 2016-02-06 08:02:28 PST
Created attachment 270795 [details]
Patch for relanding

Let's try to re-land this with a fix: don't throw away code unless we're navigating away from an existing history item.
Or basically only do this if the navigation is PageCache-eligible.
Comment 6 WebKit Commit Bot 2016-02-06 09:00:34 PST
Comment on attachment 270795 [details]
Patch for relanding

Clearing flags on attachment: 270795

Committed r196217: <http://trac.webkit.org/changeset/196217>
Comment 7 WebKit Commit Bot 2016-02-06 09:00:37 PST
All reviewed patches have been landed.  Closing bug.
Comment 8 Andreas Kling 2016-06-16 16:59:43 PDT
Rolled out in <https://trac.webkit.org/changeset/202139>
Comment 9 Andreas Kling 2016-06-17 05:12:35 PDT
Created attachment 281556 [details]
Patch

Same thing again, but this time we only do it if we haven't navigated in the last 2 seconds.
This looks a bit cheesy at first sight, but I can't think of a simpler fix for the excessive work problem.
Comment 10 Andreas Kling 2016-06-17 05:13:51 PDT
Created attachment 281557 [details]
Patch
Comment 11 WebKit Commit Bot 2016-06-17 05:15:02 PDT
Attachment 281557 [details] did not pass style-queue:


ERROR: Source/WebCore/platform/MemoryPressureHandler.cpp:43:  Alphabetical sorting problem.  [build/include_order] [4]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 12 Antti Koivisto 2016-06-17 05:52:54 PDT
Comment on attachment 281557 [details]
Patch

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

> Source/WebCore/platform/MemoryPressureHandler.cpp:167
> +    const auto minimumTimeSinceNavigation = std::chrono::seconds(2);

Could just say 

const auto minimumTimeSinceNavigation = 2s;
Comment 13 Andreas Kling 2016-06-17 05:57:18 PDT
Created attachment 281559 [details]
Patch for landing
Comment 14 WebKit Commit Bot 2016-06-17 06:35:33 PDT
Comment on attachment 281559 [details]
Patch for landing

Clearing flags on attachment: 281559

Committed r202166: <http://trac.webkit.org/changeset/202166>
Comment 15 WebKit Commit Bot 2016-06-17 06:35:38 PDT
All reviewed patches have been landed.  Closing bug.