Title: [231504] branches/safari-605-branch
Revision
231504
Author
[email protected]
Date
2018-05-08 12:42:15 -0700 (Tue, 08 May 2018)

Log Message

Cherry-pick r231187. rdar://problem/39987469

    Improve the performance of FontCascadeDescription's effectiveFamilies
    https://bugs.webkit.org/show_bug.cgi?id=184720
    PerformanceTests:

    Reviewed by Simon Fraser.

    This performance test calls SystemFontDatabase::systemFontCascadeList() around 2,000,000 times (before
    this patch is applied), which is roughly equivalent to the page we found the performance problem on.
    The calling pattern is roughly equivalent in this test.

    * Layout/system-ui.html: Added.

    Source/WebCore:

    <rdar://problem/38970927>

    Reviewed by Simon Fraser.

    The page that had the performance problem renders many different Chinese characters in system-ui
    with only a small number of individual fonts. It turns out we were calling into the system-ui
    machinery for each character in order to opportunistically start loading data URLs (see also:
    https://bugs.webkit.org/show_bug.cgi?id=175845). These data URLS will never represent the system
    font, so we don't need to invoke the system-ui machinery at all.

    This patch makes a 92x performance improvement on the associated performance test. This test is
    designed to test Chinese text rendered with system-ui.

    Performance test: Layout/system-ui.html

    * platform/graphics/FontCascadeFonts.cpp:
    (WebCore::opportunisticallyStartFontDataURLLoading):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231187 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-605-branch/PerformanceTests/ChangeLog (231503 => 231504)


--- branches/safari-605-branch/PerformanceTests/ChangeLog	2018-05-08 19:42:12 UTC (rev 231503)
+++ branches/safari-605-branch/PerformanceTests/ChangeLog	2018-05-08 19:42:15 UTC (rev 231504)
@@ -1 +1,52 @@
-== Rolled over to ChangeLog-2018-01-01 ==
+2018-05-08  Jason Marcell  <[email protected]>
+
+        Cherry-pick r231187. rdar://problem/39987469
+
+    Improve the performance of FontCascadeDescription's effectiveFamilies
+    https://bugs.webkit.org/show_bug.cgi?id=184720
+    PerformanceTests:
+    
+    Reviewed by Simon Fraser.
+    
+    This performance test calls SystemFontDatabase::systemFontCascadeList() around 2,000,000 times (before
+    this patch is applied), which is roughly equivalent to the page we found the performance problem on.
+    The calling pattern is roughly equivalent in this test.
+    
+    * Layout/system-ui.html: Added.
+    
+    Source/WebCore:
+    
+    <rdar://problem/38970927>
+    
+    Reviewed by Simon Fraser.
+    
+    The page that had the performance problem renders many different Chinese characters in system-ui
+    with only a small number of individual fonts. It turns out we were calling into the system-ui
+    machinery for each character in order to opportunistically start loading data URLs (see also:
+    https://bugs.webkit.org/show_bug.cgi?id=175845). These data URLS will never represent the system
+    font, so we don't need to invoke the system-ui machinery at all.
+    
+    This patch makes a 92x performance improvement on the associated performance test. This test is
+    designed to test Chinese text rendered with system-ui.
+    
+    Performance test: Layout/system-ui.html
+    
+    * platform/graphics/FontCascadeFonts.cpp:
+    (WebCore::opportunisticallyStartFontDataURLLoading):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-04-30  Myles C. Maxfield  <[email protected]>
+
+            Improve the performance of FontCascadeDescription's effectiveFamilies
+            https://bugs.webkit.org/show_bug.cgi?id=184720
+
+            Reviewed by Simon Fraser.
+
+            This performance test calls SystemFontDatabase::systemFontCascadeList() around 2,000,000 times (before
+            this patch is applied), which is roughly equivalent to the page we found the performance problem on.
+            The calling pattern is roughly equivalent in this test.
+
+            * Layout/system-ui.html: Added.
+
+    == Rolled over to ChangeLog-2018-01-01 ==

Added: branches/safari-605-branch/PerformanceTests/Layout/system-ui.html (0 => 231504)


--- branches/safari-605-branch/PerformanceTests/Layout/system-ui.html	                        (rev 0)
+++ branches/safari-605-branch/PerformanceTests/Layout/system-ui.html	2018-05-08 19:42:15 UTC (rev 231504)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<div id="target" style="width: 300px; display: none; font: 42px 'system-ui', '-apple-system';" lang="zh-CN"></div>
+<script>
+var target = document.getElementById("target");
+var style = target.style;
+
+var s = "";
+var length = 10000;
+var startCode = 0x4E00;
+for (var i = 0; i < length; ++i) {
+    s = s + String.fromCharCode(i + startCode);
+}
+
+
+function test() {
+    if (window.internals)
+        window.internals.invalidateFontCache();
+
+    style.display = "block";
+    target.offsetLeft;
+    target.textContent = s;
+    target.offsetLeft;
+    target.textContent = "";
+    style.display = "none";
+}
+
+PerfTestRunner.measureRunsPerSecond({ run: test });
+</script>
+</body>
+</html>

Modified: branches/safari-605-branch/Source/WebCore/ChangeLog (231503 => 231504)


--- branches/safari-605-branch/Source/WebCore/ChangeLog	2018-05-08 19:42:12 UTC (rev 231503)
+++ branches/safari-605-branch/Source/WebCore/ChangeLog	2018-05-08 19:42:15 UTC (rev 231504)
@@ -1,3 +1,63 @@
+2018-05-08  Jason Marcell  <[email protected]>
+
+        Cherry-pick r231187. rdar://problem/39987469
+
+    Improve the performance of FontCascadeDescription's effectiveFamilies
+    https://bugs.webkit.org/show_bug.cgi?id=184720
+    PerformanceTests:
+    
+    Reviewed by Simon Fraser.
+    
+    This performance test calls SystemFontDatabase::systemFontCascadeList() around 2,000,000 times (before
+    this patch is applied), which is roughly equivalent to the page we found the performance problem on.
+    The calling pattern is roughly equivalent in this test.
+    
+    * Layout/system-ui.html: Added.
+    
+    Source/WebCore:
+    
+    <rdar://problem/38970927>
+    
+    Reviewed by Simon Fraser.
+    
+    The page that had the performance problem renders many different Chinese characters in system-ui
+    with only a small number of individual fonts. It turns out we were calling into the system-ui
+    machinery for each character in order to opportunistically start loading data URLs (see also:
+    https://bugs.webkit.org/show_bug.cgi?id=175845). These data URLS will never represent the system
+    font, so we don't need to invoke the system-ui machinery at all.
+    
+    This patch makes a 92x performance improvement on the associated performance test. This test is
+    designed to test Chinese text rendered with system-ui.
+    
+    Performance test: Layout/system-ui.html
+    
+    * platform/graphics/FontCascadeFonts.cpp:
+    (WebCore::opportunisticallyStartFontDataURLLoading):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231187 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2018-04-30  Myles C. Maxfield  <[email protected]>
+
+            Improve the performance of FontCascadeDescription's effectiveFamilies
+            https://bugs.webkit.org/show_bug.cgi?id=184720
+            <rdar://problem/38970927>
+
+            Reviewed by Simon Fraser.
+
+            The page that had the performance problem renders many different Chinese characters in system-ui
+            with only a small number of individual fonts. It turns out we were calling into the system-ui
+            machinery for each character in order to opportunistically start loading data URLs (see also:
+            https://bugs.webkit.org/show_bug.cgi?id=175845). These data URLS will never represent the system
+            font, so we don't need to invoke the system-ui machinery at all.
+
+            This patch makes a 92x performance improvement on the associated performance test. This test is
+            designed to test Chinese text rendered with system-ui.
+
+            Performance test: Layout/system-ui.html
+
+            * platform/graphics/FontCascadeFonts.cpp:
+            (WebCore::opportunisticallyStartFontDataURLLoading):
+
 2018-05-02  Jason Marcell  <[email protected]>
 
         Cherry-pick r231242. rdar://problem/39860939

Modified: branches/safari-605-branch/Source/WebCore/platform/graphics/FontCascadeFonts.cpp (231503 => 231504)


--- branches/safari-605-branch/Source/WebCore/platform/graphics/FontCascadeFonts.cpp	2018-05-08 19:42:12 UTC (rev 231503)
+++ branches/safari-605-branch/Source/WebCore/platform/graphics/FontCascadeFonts.cpp	2018-05-08 19:42:15 UTC (rev 231504)
@@ -389,14 +389,8 @@
     // asynchronous, and this code doesn't actually fix the race - it just makes it more likely for the two fonts to tie in the race.
     if (!fontSelector)
         return;
-    for (unsigned i = 0; i < description.effectiveFamilyCount(); ++i) {
-        auto visitor = WTF::makeVisitor([&](const AtomicString& family) {
-            fontSelector->opportunisticallyStartFontDataURLLoading(description, family);
-        }, [&](const FontFamilyPlatformSpecification&) {
-        });
-        const auto& currentFamily = description.effectiveFamilyAt(i);
-        WTF::visit(visitor, currentFamily);
-    }
+    for (unsigned i = 0; i < description.familyCount(); ++i)
+        fontSelector->opportunisticallyStartFontDataURLLoading(description, description.familyAt(i));
 }
 
 GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 character, const FontCascadeDescription& description, FontVariant variant, unsigned fallbackIndex)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to