Let's see if there are any perf wins.
Created attachment 408751 [details] Microbenchmark On this microbenchmark, we spend 67% of the time looking up fonts (inside CTFontDescriptorCreateMatchingFontDescriptor() or CTFontDescriptorCreateMatchingFontDescriptors()).
Created attachment 408801 [details] Patch
Created attachment 408802 [details] Patch
Created attachment 408805 [details] Patch
Created attachment 408806 [details] Microbenchmark
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
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
Created attachment 408902 [details] WIP
Created attachment 408991 [details] Patch
Created attachment 409001 [details] Patch
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
Created attachment 409002 [details] Patch
Created attachment 409004 [details] Patch
Created attachment 409005 [details] Patch
Created attachment 409006 [details] Patch
Created attachment 409009 [details] Patch
See also: <rdar://problem/68579484>
Created attachment 409069 [details] Patch
Remaining task: Most tests allow user-installed fonts, which won't hit this codepath. Do something to be more confident in this patch
Created attachment 409097 [details] Patch
Created attachment 409172 [details] Patch
Created attachment 409196 [details] Patch
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>
<rdar://problem/69330831>
I also filed <rdar://problem/69389335>
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.
Created attachment 417673 [details] Patch
Created attachment 417684 [details] Patch
This is fixed by rdar://68579484.