Merged
Conversation
oliver-sanders
commented
Apr 10, 2025
Comment on lines
+513
to
+517
| if not (self.tree_walker): | ||
| self.tree_walker = urwid.TreeWalker(topnode) | ||
| self.listbox.body = self.tree_walker | ||
| else: | ||
| self.tree_walker.set_focus(topnode) |
Member
Author
There was a problem hiding this comment.
Unrelated, there is a nicer way to do this now.
oliver-sanders
commented
Apr 10, 2025
| importlib_metadata>=5.0; python_version < "3.12" | ||
| # NOTE: exclude two urwid versions that were not compatible with Tui | ||
| urwid==2.*,!=2.6.2,!=2.6.3 | ||
| urwid>=2.2,!=2.6.2,!=2.6.3,<3 |
Member
Author
There was a problem hiding this comment.
Unrelated, drop support for urwid <2.2
* Urwid has a cache (CanvasCache) that caches the render of each widget to speed up future render cycles. * Tui is a dynamic tool, it creates a new TuiNode for each update. * The old TuiNode and its child nodes were not being cleared out of the urwid cache preventing Python's garbage clearance from doing its job. * This change explicitly clears the urwid cache for each Tui update. * Preserving the cache post-update isn't really a performance boost for Tui as pretty much every node on the screen has changed anyway (besides the application header and footer). So this is likely of little consequence performance wise. The cache is still active between updates so things like expand/collapse operations will still benefit.
091c147 to
d9919ee
Compare
hjoliver
approved these changes
Apr 10, 2025
Member
hjoliver
left a comment
There was a problem hiding this comment.
Confirmed with a quick profiler run as per your instructions. Nice.
Member
Author
|
@wxtim, could you give this a quick sanity check. |
wxtim
approved these changes
Apr 11, 2025
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.
Fix a slow memory leak in Tui:
How to test:
memrayprofiler didn't seem to pick up on this issue (I guess caches are unlikely to be noticed by an internal sampling profiler).memory_profiler, but you can also spot it by counting objects usingpympler.muppy.mprof attach PID.mprof graph $PWD/<data-file>.Example output from memory_profiler before:
And after:
Check List
CONTRIBUTING.mdand added my name as a Code Contributor.setup.cfg(andconda-environment.ymlif present).?.?.xbranch.