-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
0.12
to 0.13
performance regressions
#76
Comments
Strange. There were no logic changes. It was mostly new stuff and extensive refactoring. |
If we zero in on the benchmarks here (using SourceSansPro-Regular.ttf) I wonder why I had a look but can't see any obvious reason the newer code would be slower. Perhaps the refactor is just less optimizable? |
I messed about with the code a bit last night and managed to make a faster With #77 the downstream benches are 10-20% slower (rather than 30-50%), so even merging that this isn't totally resolved 😞 |
Based on my profiling, it seems like Rust doesn't like new indirect logic in Solutions:
PS: I've pushed a commit with some explicit inlining. It made cmap slightly faster. For some reason, rustc skips some obviously simple methods. |
Can confirm. On my hardware, current So basically the "solution" is to use something like: for subtable in face.tables().cmap?.subtables {
if !encoding.is_unicode() {
continue;
}
for c in chars {
if let Some(id) = subtable.glyph_index(c) {
// store Glyph ID
}
}
} |
Ah yes, I see now. I never looked as closely at the code before so didn't think about By re-using the parsed subtables here (& doing similarly for kerning) I see regressions turned to improvements (10-30%) over the previous versions 👍 |
Nice! This was a yet another reason to make internals public. Yes, TrueType is endlessly complicated and you have to have a pretty good understanding of how it works. So making a high-level api is an obvious choice for a library. But turns out that people who use ttf-parser doesn't actually want a high-level api. It only gets in the way. I don't plan removing it anytime soon, but from now, the preferable usage is to access TrueType tables directly. Where high-level api is more like a usage example. |
Hey, behaviourally
0.13
is good for me now. However, running the benchmarks in ab_glyph suggests there are performance regressions with the latest version. I'm currently seeing 30-50% slower layout performance there on0.13
.Looking at your benches here they don't look too bad. Maybe the
glyph_index_u41
bench regression is related? Certainly that's done a lot during layout. The other layouty ones look ok.If I get some time I'll try to contribute a layout benchmark. Mostly its calling glyph-index + kern + h-advance for each glyph, so a bench calling those for each char in a paragraph should capture it fairly well.
The text was updated successfully, but these errors were encountered: