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

Trim cosmic-text's shape run cache #15037

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

UkoeHB
Copy link
Contributor

@UkoeHB UkoeHB commented Sep 3, 2024

Objective

Solution

  • Add a system to trim the cache.
  • Add an average fps indicator to the text_debug example.

Testing

Tested with cargo run --example text_debug.

  • No shape run cache: 82fps with ~1fps variance.
  • Shape run cache no trim: 90-100fps with ~2-4fps variance
  • Shape run cache trim age = 1: 90-100fps with ~2-8fps variance
  • Shape run cache trim age = 2: 90-100fps with ~2-4fps variance
  • Shape run cache trim age = 2000: 80-120fps with ~2-6fps variance

The shape run cache seems to increase average FPS but also increases frame time variance (when there is dynamic text).

@alice-i-cecile alice-i-cecile added C-Performance A change motivated by improving speed, memory usage or compile times A-Text Rendering and layout for characters S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 3, 2024
@alice-i-cecile alice-i-cecile added this to the 0.15 milestone Sep 3, 2024
/// We assume only text updated every tick benefits from the shape cache (e.g. animated text, or
/// text that is dynamically measured for UI).
pub(crate) fn trim_cosmic_cache(mut pipeline: ResMut<TextPipeline>) {
pipeline.font_system_mut().shape_run_cache.trim(2);
Copy link
Member

Choose a reason for hiding this comment

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

A comment here on why the trim value was chosen would be really helpful.

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Sep 3, 2024

Good investigation. Based on those numbers, I think "shape run cache no trim" is my preferred setting here, but I'm open to being convinced otherwise.

@UkoeHB
Copy link
Contributor Author

UkoeHB commented Sep 4, 2024

Based on those numbers, I think "shape run cache no trim" is my preferred setting here, but I'm open to being convinced otherwise.

With no trimming whatsoever the cache has unbounded growth.

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Sep 10, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 10, 2024
Merged via the queue into bevyengine:main with commit fa51e26 Sep 10, 2024
27 checks passed
@UkoeHB UkoeHB deleted the cosmic_cleanup branch September 17, 2024 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Text Rendering and layout for characters C-Performance A change motivated by improving speed, memory usage or compile times S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants