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

Speed up reflow when resizing flamegraphs with a monospace font #262

Merged
merged 14 commits into from Oct 24, 2022

Conversation

itamarst
Copy link
Contributor

@itamarst itamarst commented Sep 27, 2022

This addresses #256 partially; variable-width fonts aren't addressed.

By having two passes, one for reading attributes and one for writing attributes, we avoid refreshing the screen a bazillion times, as recommended by https://web.dev/avoid-large-complex-layouts-and-layout-thrashing/.

I tested this by rendering the input file attached in one of the comments on #256 and resizing the window, in both Chrome and Firefox, and with both variations of text truncation. On my very fast desktop, with a monospace font the resize is in real-time, and with variable-width font there is a noticeable pause before refresh happens.

Before merging I should probably at least:

  • Make known_font_size calculation only happen once
  • Add some comments (based on above) explaining why code is structured the way it is

@codecov
Copy link

codecov bot commented Sep 28, 2022

Codecov Report

Base: 90.33% // Head: 90.33% // No change to project coverage 👍

Coverage data is based on head (604c7fe) compared to base (9676e33).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #262   +/-   ##
=======================================
  Coverage   90.33%   90.33%           
=======================================
  Files          19       19           
  Lines        4241     4241           
=======================================
  Hits         3831     3831           
  Misses        410      410           
Impacted Files Coverage Δ
src/flamegraph/mod.rs 97.94% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@itamarst
Copy link
Contributor Author

itamarst commented Sep 28, 2022

See attached files to get a sense of the impact, specifically you should resize the window and notice how responsive refreshes are.
result.zip

@itamarst
Copy link
Contributor Author

Added zoom() support too, so now the refresh on startup is faster.
result.zip

Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

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

This generally looks good to me, just had a couple of questions

src/flamegraph/flamegraph.js Outdated Show resolved Hide resolved
src/flamegraph/flamegraph.js Outdated Show resolved Hide resolved
src/flamegraph/flamegraph.js Show resolved Hide resolved
src/flamegraph/flamegraph.js Show resolved Hide resolved
src/flamegraph/flamegraph.js Show resolved Hide resolved
@itamarst
Copy link
Contributor Author

Given this only addresses monospace fonts, perhaps the default font should be monospace for now?

jonhoo
jonhoo previously approved these changes Oct 22, 2022
Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

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

Could you post a screenshot of a decently-busy flamegraph with and without monospace fonts? I'd like to see how much of a detriment it is to the appearance.

Also, would you mind updating the changelog?

@itamarst
Copy link
Contributor Author

Screenshot from 2022-10-23 17-44-41

I will update changelog once you decide whether you want to change to monospace by default or not.

@jonhoo
Copy link
Owner

jonhoo commented Oct 23, 2022

Yeah, looks reasonable to me — let's update the default!

Copy link
Owner

@jonhoo jonhoo left a comment

Choose a reason for hiding this comment

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

Thanks! Will cut a release once I get a chance.

@jonhoo jonhoo merged commit 53f26b1 into jonhoo:main Oct 24, 2022
@jonhoo
Copy link
Owner

jonhoo commented Oct 25, 2022

Released as 0.11.12 🎉

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.

None yet

3 participants