Repository navigation
Improvements to TUI rendering efficiency - #332
Merged
maximmaxim345 merged 4 commits intoDec 1, 2026
Merged
Conversation
On my Ryzen 1800X I have a lot of issues with stuttering when the TUI is at large-ish resolutions. I profiled the TUI and realised that the `rich` library is quite inefficient. An ideal solution would be to move to using `curses` instead, but that would be a lot of work. Instead, I have focussed on reducing the number of expensive calls present in the hot-path. These changes involve caching the widths and heights of various TUI elements, only invalidating these caches when the terminal is resized. This saves making many calls to various heavy "measure" functions every frame. These changes reduce the time to output a "frame" of text by over 50% on average, according to profiling.sampling. Unfortunately this is still not enough to eliminate stuttering issues on my PC, but it's a step in the right direction.
Contributor
Author
The visualizer lost its bottom row or left a blank one after a title or status message wrapped differently, until the next resize.
maximmaxim345
approved these changes
Dec 1, 2026
maximmaxim345
left a comment
Member
There was a problem hiding this comment.
Thanks @YoshiWalsh!
Pushed two small fixes and a test on top. The visualizer now keeps the right height when a title or status message wraps onto another line, and cached panel widths are now measured again after a resize.
Tested side by side with main in a group on a Music Assistant dev server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


What does this implement/fix?
On my Ryzen 1800X I have a lot of issues with stuttering when the TUI is at large-ish resolutions. I profiled the TUI and realised that the
richlibrary is quite inefficient. An ideal solution would be to move to usingcursesinstead, but that would be a lot of work. Instead, I have focussed on reducing the number of expensive calls present in the hot-path.These changes involve caching the widths and heights of various TUI elements, only invalidating these caches when the terminal is resized. This saves making many calls to various heavy "measure" functions every frame.
These changes reduce the time to output a "frame" of text by ~20% on average, according to profiling.sampling. Unfortunately this is still not enough to eliminate stuttering issues on my PC, but it's a step in the right direction.
Related issue (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies