This is the continuation of 782220, likely a WontFix. We gain performance on other platforms with the hb_set changes. Due to the interactions between HarfBuzz and FreeType for autohinting, we see impact on some of the benchmark sites on Linux.
We can try to collect the fonts that are used in those benchmarks and see if they contain particular hard cases for autohinting and try to tune hb_set page size further.
Behdad, for browse_news_cnn, browse_news_hackernews and browse_social_twitter I deduplicated and collected the fonts at the shaping stage [1] and dumped them using their family name, SkTypeface::uniqueId() (which hints at the order in which they were used), and the full blob (these include system fonts as well as web fonts, without distinction.)
The ZIP including all those is here, shared with you:
https://drive.google.com/file/d/1dJO3S1IwZBITcN5lYY-Im94ZxH2qxp7Z/view?usp=sharing
I'm attaching 'benchmark_stories_font_list.txt' which contains the list of found fonts.
Can you take a look, and perhaps benchmark those against the hb_set changes? Do you see any patterns?
FWIW, what I find slightly curious is that we get Chandas in all cases, which I believe is a Devanagari font. Perhaps fontconfig decides to return this as font fallback for something.
[1] https://chromium-review.googlesource.com/c/chromium/src/+/827070/1/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp
Just loading Chandas using FreeType with HB enabled takes half a second with pagesize=512!!!! And yes, with old set, it was five times faster!
We've found the culprit. Let me see what's going on. Something *very* curious going on. Even with a pagesize of 64k, old impl is four times faster in both of my benchmarks. That's so weird but imaginable.
The slowdown is expected, given that new set does more work in add(). The real problem is that add() is called 50M times in this font. I believe I can adjust my algorithms somewhere to do significantly less work.
Oh and the font is definitely unique in that it has a 600KB GPOS table.
I've never ever seen anything like that.
To be continued...
So, basically, Chandas is full of garbage... I've made HarfBuzz detect this and bail out. Will push that to master soon. At some point I like to add a work counter to collect_glyphs() to protect against malicious fonts as well.
Comment 1 by 42576172...@developer.gserviceaccount.com
, Dec 14 2017