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

Performance improvements #308

Open
2 of 13 tasks
UkoeHB opened this issue Sep 2, 2024 · 0 comments
Open
2 of 13 tasks

Performance improvements #308

UkoeHB opened this issue Sep 2, 2024 · 0 comments

Comments

@UkoeHB
Copy link
Contributor

UkoeHB commented Sep 2, 2024

Areas for perf improvement:

  • Buffer::set_text can be optimized in a similar fashion to Big optimizations for Buffer::set_rich_text #303.
  • Use SmallVec instead of Vec where it makes sense. This should somewhat reduce the cost to make new buffers.
  • There are two allocations at the top of set_rich_text that can be moved to ShapeBuffer.
  • Internally, ShapeLine is essentially a Vec<Vec<Vec<ShapeGlyph>>>. This can be flattened into two vecs: a vec of indices + metadata and a vec of ShapeGlyphs. Or even one vec with the metadata in-line.
    • I attempted this but got stuck on the need to sometimes reverse words and glyphs in ShapeSpan. It may be less efficient to reverse elements of a flattened vec than the current implementation.
  • Internally, BufferLine caches a Vec<LayoutLine>, which is essentially Vec<Vec<LayoutGlyph>>. This could also be flattened.
    • The challenge here is needing/using [LayoutGlyph] in the layout iterator. We would no longer have access to a raw slice of glyphs.
  • Buffer caches a ShapeBuffer but it would be better to have this in FontSystem or elsewhere for global reuse.
  • FontFallbackIter::monospace_fallbacks can be injected or reused from FontSystem
  • shape_fallback() returns a Vec that isn’t reused, and takes a Vec of glyphs. These can be moved to ShapeBuffer.
  • ShapeLine::adjust_levels produces a Vec that can be cached.
  • ShapeLine::build makes a new unicode_bidi::BidiInfo every time, which contains multiple allocations.
    • Sadly, unicode-bidi is not designed to let you reuse allocations. wizterm-bidi looks like it might be more performant, but the API is more restricted and I got stuck trying to test it out (it also doesn't support no-std).
  • ShapeLine::reorder allocates twice internally.
  • BidiParagraphs makes a new unicode_bidi::BidiInfo when constructed, which allocates multiple times.
  • ShapeLineKey uses allocations that could be cached. It's also pretty expensive to hash.
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

No branches or pull requests

1 participant