Bug 157749

Summary: Regression(r177786): GlyphMetricsMap<T>::locatePageSlowCase() fills existing pages with unknown metrics
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: WebCore Misc.Assignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, darin, gyuyoung.kim, koivisto, mmaxfield
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 139971    
Attachments:
Description Flags
Patch none

Description Chris Dumez 2016-05-16 13:24:32 PDT
GlyphMetricsMap<T>::locatePageSlowCase() fills existing pages with unknown metrics after <http://trac.webkit.org/changeset/177786>. Previously, we would only to this for new pages.
Comment 1 Chris Dumez 2016-05-16 13:38:57 PDT
Created attachment 279040 [details]
Patch
Comment 2 Chris Dumez 2016-05-16 13:39:09 PDT
Still testing locally.
Comment 3 Chris Dumez 2016-05-16 13:47:01 PDT
Found this by looking at PLT profiles that seeing that WebCore::GlyphMetricsMap<WebCore::FloatRect>::locatePageSlowCase(unsigned int) is slow.
Comment 4 Antti Koivisto 2016-05-17 11:08:18 PDT
Comment on attachment 279040 [details]
Patch

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

Nice find, r=me

> Source/WebCore/platform/graphics/GlyphMetricsMap.h:123
> +    auto& pageInMap = m_pages->add(pageNumber, nullptr).iterator->value;
> +    if (!pageInMap)
> +        pageInMap = std::make_unique<GlyphMetricsPage>(unknownMetrics());
> +    return *pageInMap;

If you want to be fancy you could do something like

return *m_pages.ensure(pageNumber, [] { 
   return std::make_unique<GlyphMetricsPage>(unknownMetrics(); }
).iterator->value;
Comment 5 WebKit Commit Bot 2016-05-17 11:30:06 PDT
Comment on attachment 279040 [details]
Patch

Clearing flags on attachment: 279040

Committed r201023: <http://trac.webkit.org/changeset/201023>
Comment 6 WebKit Commit Bot 2016-05-17 11:30:11 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Chris Dumez 2016-05-18 09:02:17 PDT
Looks like a ~1% PLT progression on Mac.
Comment 8 Chris Dumez 2016-05-18 09:03:45 PDT
(In reply to comment #7)
> Looks like a ~1% PLT progression on Mac.

Ditto on iOS.