Bug 190312

Summary: Prewarm FontDatabase on process swap
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, beidson, cdumez, commit-queue, ews-watchlist, ggaren, mmaxfield, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
patch
none
patch
none
patch
none
patch
cdumez: review+
patch none

Description Antti Koivisto 2018-10-05 07:48:46 PDT
Prewarm process using cached information about the fonts the page likely needs.
Comment 1 Antti Koivisto 2018-10-05 08:44:24 PDT
Created attachment 351675 [details]
patch
Comment 2 Alex Christensen 2018-10-05 11:13:46 PDT
Comment on attachment 351675 [details]
patch

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

> Source/WebCore/page/PrewarmInformation.h:52
> +        return { };

std::nullopt

> Source/WebKit/UIProcess/WebProcessPool.h:702
> +    HashMap<String, std::unique_ptr<WebCore::PrewarmInformation>> m_prewarmInformationForRegistrableDomain;

It seems like the map should not have unique_ptr values.  Why not HashMap<String, WebCore::PrewarmInformation>?

> Source/WebKit/WebProcess/WebProcess.h:252
>      void prewarm();
> +    void prewarmWithDomainInformation(const WebCore::PrewarmInformation&);

Do we need both of these?
Comment 3 Antti Koivisto 2018-10-05 11:35:57 PDT
> It seems like the map should not have unique_ptr values.  Why not
> HashMap<String, WebCore::PrewarmInformation>?

Complex structures as map values are a bad idea as rehashing can involve lots of copying. PrewarmInformation is not that complex yet but the idea is for it to be expandable.

> > Source/WebKit/WebProcess/WebProcess.h:252
> >      void prewarm();
> > +    void prewarmWithDomainInformation(const WebCore::PrewarmInformation&);
> 
> Do we need both of these?

First one is for general prewarming that doesn't require any context and is done right after process creation. The seconds one requires we know the domain and happens on the first page load in the process.

Some renaming might be good to clarify this.
Comment 4 Alex Christensen 2018-10-05 11:42:16 PDT
Comment on attachment 351675 [details]
patch

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

> Source/WebKit/UIProcess/WebProcessPool.cpp:2268
> +    auto& value = m_prewarmInformationForRegistrableDomain.ensure(registrableDomain, [] {
> +        return std::make_unique<WebCore::PrewarmInformation>();
> +    }).iterator->value;
> +
> +    *value = prewarmInformation;

I agree with using std::unique_ptr for the key now, but could we call set instead of ensure, creating an empty structure, then copying values into it?
Comment 5 Antti Koivisto 2018-10-08 00:51:28 PDT
> I agree with using std::unique_ptr for the key now, but could we call set
> instead of ensure, creating an empty structure, then copying values into it?

I don't see how that would be better.
Comment 6 Antti Koivisto 2018-10-08 02:25:08 PDT
Created attachment 351764 [details]
patch
Comment 7 Antti Koivisto 2018-10-08 02:26:05 PDT
> std::nullopt

Why?
Comment 8 Antti Koivisto 2018-10-08 03:44:14 PDT
Created attachment 351766 [details]
patch
Comment 9 Antti Koivisto 2018-10-08 04:11:52 PDT
Created attachment 351768 [details]
patch
Comment 10 Chris Dumez 2018-10-08 09:23:35 PDT
Comment on attachment 351768 [details]
patch

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

r=me

> Source/WebKit/UIProcess/WebProcessPool.h:702
> +    HashMap<String, std::unique_ptr<WebCore::PrewarmInformation>> m_prewarmInformationForRegistrableDomain;

It seems we use PerRegistrableDomain naming above, let's be consistent?
Comment 11 Antti Koivisto 2018-10-09 00:52:57 PDT
Created attachment 351869 [details]
patch
Comment 12 WebKit Commit Bot 2018-10-09 02:14:44 PDT
Comment on attachment 351869 [details]
patch

Clearing flags on attachment: 351869

Committed r236959: <https://trac.webkit.org/changeset/236959>
Comment 13 WebKit Commit Bot 2018-10-09 02:14:46 PDT
All reviewed patches have been landed.  Closing bug.
Comment 14 Radar WebKit Bug Importer 2018-10-09 02:15:23 PDT
<rdar://problem/45120617>