Skip to content
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

Tweak is_nonspacing_mark_name based on flamegraph #395

Merged
merged 4 commits into from
Aug 15, 2023
Merged

Tweak is_nonspacing_mark_name based on flamegraph #395

merged 4 commits into from
Aug 15, 2023

Conversation

rsheeter
Copy link
Contributor

@rsheeter rsheeter commented Aug 10, 2023

Before change is_nonspacing_mark reports as ~4% of total time and a major part of GlyphIrWork:

image

Essentially all the time was spent on partial eq for str so in this PR I try to avoid that by exiting early when the str could not possibly match.

After change it reports as ~1.5% and while still visible it no longer dominates GlyphIrWork:

image

Tested using Oswald.

@rsheeter rsheeter changed the title [WIP] Tweak is_nonspacing_mark_name based on flamegraph Tweak is_nonspacing_mark_name based on flamegraph Aug 10, 2023
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so to check my understanding:

  • we have, from fonttools, a list of the names of all possible nonspacing marks
  • for all our glyph names, we need to check if they're on that list

I wonder what other approaches might work for us? One option would be a compile-time perfect hash function, using a crate such as https://docs.rs/phf/latest/phf/? Apparently this also has a codegen mode, so we wouldn't necessarily even need to bring it in as a dep.

It might be worth at least trying that, and seeing what the perf looks like?

glyphs2fontir/src/glyphdata.rs Show resolved Hide resolved
glyphs2fontir/src/glyphdata.rs Outdated Show resolved Hide resolved
@rsheeter
Copy link
Contributor Author

I have deferred exploration of phf, which does seem potentially promising, to #399

@rsheeter rsheeter merged commit a4ee74c into main Aug 15, 2023
8 checks passed
@rsheeter rsheeter deleted the fg2 branch August 15, 2023 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants