Bug 185411 - [Simple line layout] Cache run and line resolvers.
Summary: [Simple line layout] Cache run and line resolvers.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: zalan
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-05-07 20:32 PDT by zalan
Modified: 2018-05-08 17:20 PDT (History)
6 users (show)

See Also:


Attachments
Patch (12.44 KB, patch)
2018-05-07 20:44 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (12.49 KB, patch)
2018-05-08 10:58 PDT, zalan
no flags Details | Formatted Diff | Diff
Patch (12.75 KB, patch)
2018-05-08 14:51 PDT, zalan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zalan 2018-05-07 20:32:56 PDT
Whenever a (run/line)resolver is constructed (for painting/hit testing) we iterate through and collect all the flow's content in FlowContents's c'tor.
In case of long text content with large amount of elements (foobar1<br>foobar2<br>.....foobar9999<br>) this repeated work could hang the WebProcess.
Comment 1 zalan 2018-05-07 20:44:13 PDT
Created attachment 339794 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2018-05-07 20:44:55 PDT
<rdar://problem/40047659>
Comment 3 Antti Koivisto 2018-05-08 08:31:38 PDT
Comment on attachment 339794 [details]
Patch

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

> Source/WebCore/rendering/SimpleLineLayout.cpp:979
> +    , m_runResolver(std::make_unique<RunResolver>(blockFlow, *this))
> +    , m_lineResolver(std::make_unique<LineResolver>(*m_runResolver))

Doesn't this massively increase memory use of simple line layout? FlowContents objects have way more per-line memory use than Layout, that's why they have been temporaries so far. Can we have a cache that is created on-demand and goes away when not needed (with a timer for example).
Comment 4 zalan 2018-05-08 08:34:42 PDT
Comment on attachment 339794 [details]
Patch

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

>> Source/WebCore/rendering/SimpleLineLayout.cpp:979
>> +    , m_lineResolver(std::make_unique<LineResolver>(*m_runResolver))
> 
> Doesn't this massively increase memory use of simple line layout? FlowContents objects have way more per-line memory use than Layout, that's why they have been temporaries so far. Can we have a cache that is created on-demand and goes away when not needed (with a timer for example).

Absolutely! I was going to create them on demand (hence the std::unique<>). -though destroying them on a timer didn't occur to me. That's a good idea.
Comment 5 Antti Koivisto 2018-05-08 08:47:24 PDT
Actually since FlowContents::Segments are per-renderer, the resolvers are not that big in any reasonable case (and unreasonable ones benefit from caching). I think this approach is actually fine as-is. You probably don't need to cache RunResolver and LineResolver separately though.
Comment 6 zalan 2018-05-08 10:58:36 PDT
Created attachment 339834 [details]
Patch
Comment 7 Antti Koivisto 2018-05-08 11:43:41 PDT
Comment on attachment 339834 [details]
Patch

r=me
Comment 8 zalan 2018-05-08 14:51:47 PDT
Created attachment 339885 [details]
Patch
Comment 9 WebKit Commit Bot 2018-05-08 17:20:25 PDT
Comment on attachment 339885 [details]
Patch

Clearing flags on attachment: 339885

Committed r231529: <https://trac.webkit.org/changeset/231529>
Comment 10 WebKit Commit Bot 2018-05-08 17:20:26 PDT
All reviewed patches have been landed.  Closing bug.