Skip to content

Commit

Permalink
tui: Merge threads in the live mode TUI by default
Browse files Browse the repository at this point in the history
Allow users to opt out when they want to see what individual threads are
allocating. This is a better default, since it more closely matches what
the other reporters do, but still allows power users to opt in to
getting more information (and a busier UI).

Signed-off-by: Matt Wozniski <[email protected]>
  • Loading branch information
godlygeek committed May 30, 2024
1 parent 04789eb commit 2ebca3f
Show file tree
Hide file tree
Showing 4 changed files with 695 additions and 691 deletions.
7 changes: 4 additions & 3 deletions docs/live.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ The sorted column's heading is underlined.
Viewing different threads
-------------------------

By default, the ``live`` command will present the main thread of the program. You can look at different threads of the
program by pressing the greater than and less than keys, ``<`` and ``>``. In most terminals you can also click the
"Previous Thread" and "Next Thread" buttons on the footer.
By default, the ``live`` command will present allocations from all of the program's threads. You can look at individual
threads of the program by first pressing ``m`` (to disable thread merging), and then pressing the greater than and less
than keys, ``<`` and ``>``, to switch between threads. In most terminals you can also click the "Unmerge Threads",
"Previous Thread", and "Next Thread" buttons on the footer.

.. image:: _static/images/live_different_thread.png

Expand Down
4 changes: 2 additions & 2 deletions src/memray/reporters/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@ class TUI(Screen[None]):
BINDINGS = [
Binding("ctrl+z", "app.suspend_process"),
Binding("q,esc", "app.quit", "Quit"),
Binding("m", "toggle_merge_threads", "Merge Threads"),
Binding("<,left", "previous_thread", "Previous Thread"),
Binding(">,right", "next_thread", "Next Thread"),
Binding("m", "toggle_merge_threads", "Merge Threads"),
Binding("t", "sort(1)", "Sort by Total"),
Binding("o", "sort(3)", "Sort by Own"),
Binding("a", "sort(5)", "Sort by Allocations"),
Expand All @@ -547,7 +547,7 @@ def __init__(self, pid: Optional[int], cmd_line: Optional[str], native: bool):
self.native = native
self._seen_threads: Set[int] = set()
self._max_memory_seen = 0
self._merge_threads = False
self._merge_threads = True
super().__init__()

@property
Expand Down
Loading

0 comments on commit 2ebca3f

Please sign in to comment.