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

[GuiAdvancedScrollText] Performance improvements #2019

Merged

Conversation

csibbitt
Copy link
Contributor

@csibbitt csibbitt commented Oct 10, 2023

Fixes Issue #1939

Most of the work is from @oznogon , I just added some finishing touches.

This refactors GuiAdvancedScrollText to improve render performance.

  • Font prep is moved to addEntry, and FontPreparedStrings are stored in the entries. This means fonts for an entry are prepared once upon the entry's addition, not each frame. This improves render performance, especially with large texts.
  • Font prep is repeated across all entries only if the window width changes.
  • Content outside the bottom of the scroll rect is ignored on the text-rendering step, rather than rendered and then clipped. This improves render performance when scrolling to the top of the text.
  • max_prefix_width is calculated upon entry addition/removal rather than each frame.

Testing on a variety of systems with a 10,000-entry log, this maintains:

  • 20fps on a 12th-gen/16-thread i5 on Intel graphics, with power-saving enabled (previously: 2.8)
  • 40fps on a 12th-gen/16-thread i5 on Intel graphics (previously: 4)
  • 51fps on a 16-thread Ryzen 9/RTX 3060 (previously: 9)

Known issues:

  • Resizing the window with a large text is as expensive as before this PR, since this is now the only time the entire entries list is prepared at once.

oznogon and others added 9 commits October 9, 2023 22:41
Prepare fonts for entries only when adding an entry, rather than
for every entry on every frame.
Re-prep fonts to reflow and recalculate entry height when the
window width changes. This causes significant performance impacts
when resizing the window with a large log.
* Refactored Entry font prep and max prefix tracking to its own method
* Added a map for tracking prefix lengths
* When removing Entries, update max_prefix_width if necesarry
* Reset max_prefix_width (and tracking map) when resizing or clearing Entries
* Needs to account for draw_offset alignment kludge
@daid daid merged commit 070ca6a into daid:master Oct 16, 2023
7 checks passed
Tsht pushed a commit to Tsht/EmptyEpsilon that referenced this pull request Nov 22, 2023
* [GuiAdvancedScrollText] Move prefix width calculation to addEntry

* [GuiAdvancedScrollText] Disregard text that would be drawn below rect

* [GuiAdvancedScrollText] Use unsigned ints for indexes

* [GuiAdvancedScrollText] Move font prep from onDraw to addEntry

Prepare fonts for entries only when adding an entry, rather than
for every entry on every frame.

* [GuiAdvancedScrollText] Re-prep fonts when window width changes

Re-prep fonts to reflow and recalculate entry height when the
window width changes. This causes significant performance impacts
when resizing the window with a large log.

* [GuiAdvancedScrollText] Track max_prefix_width when adding/removing

* Refactored Entry font prep and max prefix tracking to its own method
* Added a map for tracking prefix lengths
* When removing Entries, update max_prefix_width if necesarry
* Reset max_prefix_width (and tracking map) when resizing or clearing Entries

* [GuiAdvancedScrollText] Fix the latest-line view on Relay startup

* Needs to account for draw_offset alignment kludge

* [GuiAdvancedScrollText][NO-OP] Simplify prepEntry signature

* [GuiAdvancedScrollText] Fix bounds check in removeEntry

* [GuiAdvancedScrollText] Revert to signed ints for indexes

---------

Co-authored-by: oznogon <[email protected]>
@csibbitt csibbitt deleted the csibbitt-guiadvancedscrolltext-performance-tweak branch June 27, 2024 03:13
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