Bug 116863 - Share FontGlyphs
Summary: Share FontGlyphs
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-28 05:48 PDT by Antti Koivisto
Modified: 2013-05-29 08:49 PDT (History)
11 users (show)

See Also:


Attachments
WIP (17.13 KB, patch)
2013-05-28 05:49 PDT, Antti Koivisto
webkit-ews: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2 (4.78 MB, application/zip)
2013-05-28 23:59 PDT, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion (4.14 MB, application/zip)
2013-05-29 02:52 PDT, Build Bot
no flags Details
patch (23.84 KB, patch)
2013-05-29 03:39 PDT, Antti Koivisto
webkit-ews: commit-queue-
Details | Formatted Diff | Diff
patch 2 (23.89 KB, patch)
2013-05-29 04:38 PDT, Antti Koivisto
webkit-ews: commit-queue-
Details | Formatted Diff | Diff
patch 3 (23.92 KB, patch)
2013-05-29 04:56 PDT, Antti Koivisto
kling: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2013-05-28 05:48:01 PDT
Save memory and improve performance.
Comment 1 Antti Koivisto 2013-05-28 05:49:20 PDT
Created attachment 203045 [details]
WIP
Comment 2 WebKit Commit Bot 2013-05-28 05:50:57 PDT
Attachment 203045 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/css/CSSFontSelector.cpp', u'Source/WebCore/page/Settings.cpp', u'Source/WebCore/platform/graphics/Font.cpp', u'Source/WebCore/platform/graphics/Font.h', u'Source/WebCore/platform/graphics/FontCache.cpp', u'Source/WebCore/platform/graphics/FontCache.h', u'Source/WebCore/platform/graphics/FontFallbackList.cpp', u'Source/WebCore/platform/graphics/FontFallbackList.h']" exit_code: 1
Source/WebCore/platform/graphics/Font.cpp:222:  Missing spaces around /  [whitespace/operators] [3]
Source/WebCore/platform/graphics/Font.cpp:320:  Missing spaces around /  [whitespace/operators] [3]
Source/WebCore/platform/graphics/FontFallbackList.h:93:  The parameter name "fontSelector" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 3 in 8 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Early Warning System Bot 2013-05-28 05:57:38 PDT
Comment on attachment 203045 [details]
WIP

Attachment 203045 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/724146
Comment 4 EFL EWS Bot 2013-05-28 05:58:10 PDT
Comment on attachment 203045 [details]
WIP

Attachment 203045 [details] did not pass efl-wk2-ews (efl-wk2):
Output: http://webkit-queues.appspot.com/results/742075
Comment 5 Early Warning System Bot 2013-05-28 05:59:03 PDT
Comment on attachment 203045 [details]
WIP

Attachment 203045 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/742074
Comment 6 EFL EWS Bot 2013-05-28 06:10:58 PDT
Comment on attachment 203045 [details]
WIP

Attachment 203045 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/670169
Comment 7 Build Bot 2013-05-28 06:15:21 PDT
Comment on attachment 203045 [details]
WIP

Attachment 203045 [details] did not pass win-ews (win):
Output: http://webkit-queues.appspot.com/results/715067
Comment 8 Antti Koivisto 2013-05-28 09:52:01 PDT
Looks like these are failing in bots

Regressions: Unexpected text-only failures (2)
  fast/ruby/nested-ruby.html [ Failure ]
  svg/W3C-SVG-1.1/fonts-desc-02-t.svg [ Failure ]

Regressions: Unexpected image-only failures (2)
  fast/text/international/lang-sensitive-fonts.html [ ImageOnlyFailure ]
  platform/mac/fonts/han-disunification.html [ ImageOnlyFailure ]
Comment 9 Build Bot 2013-05-28 23:59:33 PDT
Comment on attachment 203045 [details]
WIP

Attachment 203045 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/656461

New failing tests:
platform/mac/fonts/han-disunification.html
svg/W3C-SVG-1.1/fonts-desc-02-t.svg
fast/ruby/nested-ruby.html
fast/text/international/lang-sensitive-fonts.html
Comment 10 Build Bot 2013-05-28 23:59:36 PDT
Created attachment 203128 [details]
Archive of layout-test-results from webkit-ews-14 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-14  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.3
Comment 11 Build Bot 2013-05-29 02:52:44 PDT
Comment on attachment 203045 [details]
WIP

Attachment 203045 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/678085

New failing tests:
platform/mac/fonts/han-disunification.html
svg/W3C-SVG-1.1/fonts-desc-02-t.svg
fast/ruby/nested-ruby.html
fast/text/international/lang-sensitive-fonts.html
Comment 12 Build Bot 2013-05-29 02:52:47 PDT
Created attachment 203144 [details]
Archive of layout-test-results from webkit-ews-04 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-04  Port: mac-mountainlion  Platform: Mac OS X 10.8.3
Comment 13 Antti Koivisto 2013-05-29 03:39:46 PDT
Created attachment 203148 [details]
patch
Comment 14 Early Warning System Bot 2013-05-29 03:45:57 PDT
Comment on attachment 203148 [details]
patch

Attachment 203148 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/743257
Comment 15 Early Warning System Bot 2013-05-29 03:47:34 PDT
Comment on attachment 203148 [details]
patch

Attachment 203148 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/672477
Comment 16 EFL EWS Bot 2013-05-29 03:54:01 PDT
Comment on attachment 203148 [details]
patch

Attachment 203148 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/745034
Comment 17 Antti Koivisto 2013-05-29 04:38:35 PDT
Created attachment 203153 [details]
patch 2
Comment 18 Early Warning System Bot 2013-05-29 04:46:22 PDT
Comment on attachment 203153 [details]
patch 2

Attachment 203153 [details] did not pass qt-ews (qt):
Output: http://webkit-queues.appspot.com/results/689255
Comment 19 Early Warning System Bot 2013-05-29 04:47:07 PDT
Comment on attachment 203153 [details]
patch 2

Attachment 203153 [details] did not pass qt-wk2-ews (qt-wk2):
Output: http://webkit-queues.appspot.com/results/660166
Comment 20 EFL EWS Bot 2013-05-29 04:51:36 PDT
Comment on attachment 203153 [details]
patch 2

Attachment 203153 [details] did not pass efl-ews (efl):
Output: http://webkit-queues.appspot.com/results/659110
Comment 21 Antti Koivisto 2013-05-29 04:56:01 PDT
Created attachment 203185 [details]
patch 3
Comment 22 Andreas Kling 2013-05-29 07:13:53 PDT
Comment on attachment 203185 [details]
patch 3

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

Pretty neat.
r=me with some whining:

> Source/WebCore/ChangeLog:8
> +        Style system generates many Font objects that are indentical or similar enough to have identical FontGlyphs. 

Typo, identical.

> Source/WebCore/ChangeLog:10
> +        It also improves perfomrance as the glyph cache and the width cache hang from FontGlyphs and the hit rate of

Typo, performance.

> Source/WebCore/css/CSSFontSelector.cpp:69
> +    , m_uniqueId(++fontSelectorId)

Can't this overflow? You're not even using a 64-bit type!

> Source/WebCore/css/CSSFontSelector.cpp:631
> +        DEFINE_STATIC_LOCAL(String, webkitPrefix, ("-webkit-"));
> +        if (familyName.startsWith(webkitPrefix))
> +            return true;

String::startsWith() has a nice overload for this, it's better to just check startsWith("-webkit-")

> Source/WebCore/css/CSSFontSelector.h:54
> +    virtual ~CSSFontSelector() FINAL OVERRIDE;

... na-na nah nah naaaaaa!

Sorry to ruin the '80s song, but we should just mark the class FINAL instead of doing it to every virtual method.

> Source/WebCore/platform/graphics/Font.cpp:169
> +    if (a.fontDescriptionCacheKey != b.fontDescriptionCacheKey)
> +        return false;
> +    if (a.families != b.families)
> +        return false;
> +    if (a.fontSelectorId != b.fontSelectorId || a.fontSelectorVersion != b.fontSelectorVersion || a.fontSelectorFlags != b.fontSelectorFlags)
> +        return false;

I would order these comparisons by cost from lowest to highest, so we can fail faster.

> Source/WebCore/platform/graphics/Font.cpp:202
> +    if (!key.fontDescriptionCacheKey.size || key.families.isEmpty())
> +        return 0;

The families Vector should never be empty, so I don't think this test is correct.

> Source/WebCore/platform/graphics/Font.h:317
> +void pruneUnreferencedFromFontGlyphsCache();

Mildly awkward name. I'd call it pruneUnreferencedEntriesFromFontGlyphsCache(); (because reasons.)

> Source/WebCore/platform/graphics/FontCache.cpp:80
> +    FontDescriptionFontDataCacheKey m_fontDescriptioKey;

Typo, m_fontDescriptioKey.

> Source/WebCore/platform/graphics/FontCache.h:67
> +    FontDescriptionFontDataCacheKey(unsigned size = 0)

This should be marked explicit.
Comment 23 Antti Koivisto 2013-05-29 07:47:23 PDT
> > Source/WebCore/css/CSSFontSelector.cpp:69
> > +    , m_uniqueId(++fontSelectorId)
> 
> Can't this overflow? You're not even using a 64-bit type!

Yeah, in theory though that would take a while. Also it is unlikely that any fonts from a colliding font selector are alive at that point. If that happens you may get a wrong font.

> > Source/WebCore/css/CSSFontSelector.cpp:631
> > +        DEFINE_STATIC_LOCAL(String, webkitPrefix, ("-webkit-"));
> > +        if (familyName.startsWith(webkitPrefix))
> > +            return true;
> 
> String::startsWith() has a nice overload for this, it's better to just check startsWith("-webkit-")

Ok. Didn't know that.

> 
> > Source/WebCore/css/CSSFontSelector.h:54
> > +    virtual ~CSSFontSelector() FINAL OVERRIDE;
> 
> ... na-na nah nah naaaaaa!
> 
> Sorry to ruin the '80s song, but we should just mark the class FINAL instead of doing it to every virtual method.

:(
Comment 24 Antti Koivisto 2013-05-29 08:49:53 PDT
http://trac.webkit.org/changeset/150897