EmptyEpsilon icon indicating copy to clipboard operation
EmptyEpsilon copied to clipboard

[GuiAdvancedScrollText] Improve performance

Open oznogon opened this issue 1 year ago • 2 comments

Re: #1939

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 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:

  • The latest-line view on Relay doesn't render correctly upon screen load. Expanding and minimizing the log view on Relay resolves this.
  • 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.
  • max_prefix_width is retained even if the largest prefix-width entry is removed from the log. This is potentially trivial to fix.

oznogon avatar Mar 18 '23 23:03 oznogon

Ran out of spare time on this, so I'm posting it up in case someone can improve on it.

oznogon avatar Mar 18 '23 23:03 oznogon

#1947 was caught while doing this. An example of a potential fix involves checking the prefix text as well as the entry text, which requires adding a getEntryPrefix() function to GuiAdvancedScrollText. That would limit collisions to only entries with the same text at the same time in the ship's log. Another fix would be adding a UID to entries and checking that instead of the text.

oznogon avatar Mar 18 '23 23:03 oznogon