Bug 216498 - [Cocoa] Prototype fontd-less WebKit
Summary: [Cocoa] Prototype fontd-less WebKit
Status: RESOLVED MOVED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Myles C. Maxfield
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-09-14 15:16 PDT by Myles C. Maxfield
Modified: 2021-03-12 18:27 PST (History)
7 users (show)

See Also:


Attachments
Microbenchmark (882 bytes, text/html)
2020-09-14 15:17 PDT, Myles C. Maxfield
no flags Details
Patch (42.32 KB, patch)
2020-09-15 01:28 PDT, Myles C. Maxfield
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Patch (42.32 KB, patch)
2020-09-15 01:32 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (42.38 KB, patch)
2020-09-15 02:03 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Microbenchmark (1.06 KB, text/html)
2020-09-15 02:16 PDT, Myles C. Maxfield
no flags Details
WIP (40.82 KB, patch)
2020-09-16 00:17 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (42.55 KB, patch)
2020-09-16 22:49 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (33.19 KB, patch)
2020-09-17 00:33 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (33.28 KB, patch)
2020-09-17 00:43 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (33.32 KB, patch)
2020-09-17 00:52 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (33.30 KB, patch)
2020-09-17 00:57 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (33.28 KB, patch)
2020-09-17 01:00 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (33.46 KB, patch)
2020-09-17 01:20 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (36.31 KB, patch)
2020-09-17 15:13 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (36.24 KB, patch)
2020-09-17 17:56 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (36.65 KB, patch)
2020-09-18 15:00 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (36.63 KB, patch)
2020-09-18 22:50 PDT, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (33.45 KB, patch)
2021-01-14 17:56 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff
Patch (33.47 KB, patch)
2021-01-15 00:37 PST, Myles C. Maxfield
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2020-09-14 15:16:12 PDT
Let's see if there are any perf wins.
Comment 1 Myles C. Maxfield 2020-09-14 15:17:16 PDT
Created attachment 408751 [details]
Microbenchmark

On this microbenchmark, we spend 67% of the time looking up fonts (inside CTFontDescriptorCreateMatchingFontDescriptor() or CTFontDescriptorCreateMatchingFontDescriptors()).
Comment 2 Myles C. Maxfield 2020-09-15 01:28:56 PDT
Created attachment 408801 [details]
Patch
Comment 3 Myles C. Maxfield 2020-09-15 01:32:44 PDT
Created attachment 408802 [details]
Patch
Comment 4 Myles C. Maxfield 2020-09-15 02:03:20 PDT
Created attachment 408805 [details]
Patch
Comment 5 Myles C. Maxfield 2020-09-15 02:16:45 PDT
Created attachment 408806 [details]
Microbenchmark
Comment 6 Myles C. Maxfield 2020-09-15 02:38:59 PDT
This is a 2.2x speedup on the microbenchmark!!

Here are my numbers, units are ms, lower is better:

With patch:
1205
1201
1250
1272
1240
1250
1260
1249
1230
1233

Without patch:
3993
3928
3952
3987
3954
3967
3958
4048
3915
4030
Comment 7 Myles C. Maxfield 2020-09-15 21:11:34 PDT
Remaining tasks:

1. Make this patch do nothing on non-macOS ports
2. Iterate over all fonts, not just the ones returned by an empty dictionary and CTFontDescriptorCreateMatchingFontDescriptors()
3. Make sure tests pass
4. Most tests allow user-installed fonts, which won't hit this codepath. Do something to be more confident in this patch
Comment 8 Myles C. Maxfield 2020-09-16 00:17:32 PDT
Created attachment 408902 [details]
WIP
Comment 9 Myles C. Maxfield 2020-09-16 22:49:23 PDT
Created attachment 408991 [details]
Patch
Comment 10 Myles C. Maxfield 2020-09-17 00:33:02 PDT
Created attachment 409001 [details]
Patch
Comment 11 Myles C. Maxfield 2020-09-17 00:39:29 PDT
Remaining tasks:

1. Make sure tests pass
2. Most tests allow user-installed fonts, which won't hit this codepath. Do something to be more confident in this patch
3. Key the fonts on all localizations of the family name
Comment 12 Myles C. Maxfield 2020-09-17 00:43:17 PDT
Created attachment 409002 [details]
Patch
Comment 13 Myles C. Maxfield 2020-09-17 00:52:50 PDT
Created attachment 409004 [details]
Patch
Comment 14 Myles C. Maxfield 2020-09-17 00:57:55 PDT
Created attachment 409005 [details]
Patch
Comment 15 Myles C. Maxfield 2020-09-17 01:00:47 PDT
Created attachment 409006 [details]
Patch
Comment 16 Myles C. Maxfield 2020-09-17 01:20:05 PDT
Created attachment 409009 [details]
Patch
Comment 17 Myles C. Maxfield 2020-09-17 14:05:51 PDT
See also: <rdar://problem/68579484>
Comment 18 Myles C. Maxfield 2020-09-17 15:13:01 PDT
Created attachment 409069 [details]
Patch
Comment 19 Myles C. Maxfield 2020-09-17 15:56:36 PDT
Remaining task: Most tests allow user-installed fonts, which won't hit this codepath. Do something to be more confident in this patch
Comment 20 Myles C. Maxfield 2020-09-17 17:56:51 PDT
Created attachment 409097 [details]
Patch
Comment 21 Myles C. Maxfield 2020-09-18 15:00:45 PDT
Created attachment 409172 [details]
Patch
Comment 22 Myles C. Maxfield 2020-09-18 22:50:28 PDT
Created attachment 409196 [details]
Patch
Comment 23 Myles C. Maxfield 2020-09-20 23:35:20 PDT
Integrating this into Apple's build system will be quite challenging. I'll be putting this on hold to see if it's possible to solve this another way.

See also: <rdar://problem/68579484>
Comment 24 Radar WebKit Bug Importer 2020-09-21 15:17:16 PDT
<rdar://problem/69330831>
Comment 25 Myles C. Maxfield 2020-09-22 13:39:46 PDT
I also filed <rdar://problem/69389335>
Comment 26 Ben Nham 2020-11-11 15:31:30 PST
Comment on attachment 409196 [details]
Patch

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

> Source/WebCore/platform/graphics/cocoa/PreinstalledFonts.mm:119
> +        prebuiltFontFamilyMembers(familyName);

I think this should be `return prebuiltFontFamilyMembers(familyName)`. After making that change I got the expected speedup from prototyping the patch.
Comment 27 Ben Nham 2020-11-11 15:31:52 PST
Comment on attachment 409196 [details]
Patch

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

> Source/WebCore/platform/graphics/cocoa/PreinstalledFonts.mm:119
> +        prebuiltFontFamilyMembers(familyName);

I think this should be `return prebuiltFontFamilyMembers(familyName)`. After making that change I got the expected speedup from prototyping the patch.
Comment 28 Myles C. Maxfield 2021-01-14 17:56:58 PST
Created attachment 417673 [details]
Patch
Comment 29 Myles C. Maxfield 2021-01-15 00:37:43 PST
Created attachment 417684 [details]
Patch
Comment 30 Myles C. Maxfield 2021-03-12 18:27:11 PST
This is fixed by rdar://68579484.