Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Oct 11, 2022

Attempt to improve average case performance by not recreating the glyph atlas if the contents are identical

// the current atlas and reuse if possible.
// ---------------------------------------------------------------------------
if (last_atlas->GetType() == type) {
auto new_glyphs = last_atlas->FindNewGlyphs(font_glyph_pairs);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this is actually good enough of a check. If glyphs are drawn at different sizes I think we'd need to account for that ... right? But based on my reading of the code its only one FontGlyphPair mapped to each rect, so a different size glyph has to be a unique font glyph pair ... right?

Copy link
Contributor

Choose a reason for hiding this comment

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

If the glyph size changes the rect won't match.

@jonahwilliams
Copy link
Contributor Author

FYI @dnfield

@jonahwilliams
Copy link
Contributor Author

I ran some benchmarks on the flutter gallery using a newer iPhone. This is a tiny biy (0.5 -1 ms) faster, but we already know that isn't a particularly text heavy app. I'll have to try again with customer chalk when I'm back next week

@jonahwilliams
Copy link
Contributor Author

Playing around with the gallery app, I can see that on an older iPhone model (6? 7?), It can take 3-4ms to create a glyph atlas. Caching it means that the raster times for frames where the atlas is fully cached are measurably faster. This may or may not show up in synthetic benchmarks based on how quickly one "dwells" at a particular page in the app.

dnfield
dnfield previously approved these changes Oct 12, 2022
Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

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

Lgtm but like you say let's measure chalk

// ---------------------------------------------------------------------------
if (last_atlas->GetType() == type &&
last_atlas->HasSamePairs(font_glyph_pairs)) {
return last_atlas;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should file an issue to explore copying out the glyphs we still need. Or maybe just copy the whole atlas if it's small enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking something like, if you need a small number of additional glyphs and they fit on the current atlas, just append them and re-upload. Even if we resized the atlas, reusing and blitting the old atlas instead of each character would be a good idea too

Copy link
Contributor

Choose a reason for hiding this comment

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

We'd either have to keep the rect packer around or store the taken/free area somehow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this probably deserves a doc exploring the options we have here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I explored this a bit while I was out. There are a lot of potential caching options available to us, but I think we should probably keep pulling on making the whole thing faster first before we invest too much effort into tuning this.

To that end, lets land the trivial case caching and circle back?

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM

@jonahwilliams jonahwilliams marked this pull request as ready for review October 20, 2022 17:15
@jonahwilliams jonahwilliams requested a review from dnfield October 20, 2022 17:15
@chinmaygarde chinmaygarde dismissed dnfield’s stale review October 20, 2022 20:15

Jonah asks for another review pass.

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 24, 2022
@auto-submit auto-submit bot merged commit f445898 into flutter:main Oct 24, 2022
@jonahwilliams jonahwilliams deleted the vertices_copy branch October 24, 2022 17:56
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Oct 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants