git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/3] gitk: turn off undo manager in the text widget

From
Jacob Keller <jacob.keller@gmail.com>
Date
Nov 7, 2016, 22:13 UTC
Message-ID
<CA+P7+xrSb0bEC4dvEXKGLdhnunO9oyU685t6VCwd0Sj-pnOT0w@mail.gmail.com>
In-Reply-To
<e09a5309-351d-d246-d272-f527f50ad444@jump-ing.de>
On Mon, Nov 7, 2016 at 10:57 AM, Markus Hitter <mah@jump-ing.de> wrote:
Show 12 quoted lines
> From e965e1deb9747bbc2b40dc2de95afb65aee9f7fd Mon Sep 17 00:00:00 2001
> From: Markus Hitter <mah@jump-ing.de>
> Date: Sun, 6 Nov 2016 20:38:03 +0100
> Subject: [PATCH 1/3] gitk: turn off undo manager in the text widget
>
> The diff text widget is read-only, so there's zero point in
> building an undo stack. This change reduces memory consumption of
> this widget by about 95%.
>
> Memory usage of the whole program for viewing a reference commit
> before; 579'692'744 bytes, after: 32'724'446 bytes.
>
Wow. Nice find!
Show 32 quoted lines
> Test procedure:
>
>  - Choose a largish commit and check it out. In this case one with
>    90'802 lines, 5'006'902 bytes.
>
>  - Have a Tcl version with memory debugging enabled. This is,
>    build one with --enable-symbols=mem passed to configure.
>
>  - Instrument Gitk to regularly show a memory dump. E.g. by adding
>    these code lines at the very bottom:
>
>      proc memDump {} {
>          catch {
>              set output [memory info]
>              puts $output
>          }
>
>          after 3000 memDump
>      }
>
>      memDump
>
>  - Start Gitk, it'll load this largish commit into the diff text
>    field automatically (because it's the current commit).
>
>  - Wait until memory consumption levels out and note the numbers.
>
> Note that the numbers reported by [memory info] are much smaller
> than the ones reported in 'top' (1.75 GB vs. 105 MB in this case),
> likely due to all the instrumentation coming with the debug
> version of Tcl.
>

Still, this is definitely the lions share of the memory issue. Additionally, this fix seems much better overall and does not harm any other aspects of gitk, because we only read the widget so there is as you mentioned, zero reason to build an undo stack.

Thanks for taking the extra time to find a proper solution to this! I think it makes perfect sense.

Show 21 quoted lines
> Signed-off-by: Markus Hitter <mah@jump-ing.de>
> ---
>  gitk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gitk b/gitk
> index 805a1c7..8654e29 100755
> --- a/gitk
> +++ b/gitk
> @@ -2403,7 +2403,7 @@ proc makewindow {} {
>
>      set ctext .bleft.bottom.ctext
>      text $ctext -background $bgcolor -foreground $fgcolor \
> -       -state disabled -font textfont \
> +       -state disabled -undo 0 -font textfont \
>         -yscrollcommand scrolltext -wrap none \
>         -xscrollcommand ".bleft.bottom.sbhorizontal set"
>      if {$have_tk85} {
> --
> 2.9.3
>

Nice that such a simple change results in a huge gain. I think this makes perfect sense.

Regards, Jake

Previous: Markus HitterNext: Junio C Hamano
Message 5 of 9 in “gitk: memory consumption improvements”
  1. 0/3 gitk: memory consumption improvementsMarkus Hitter, Nov 7, 2016
  2. 1/3 gitk: turn off undo manager in the text widgetMarkus Hitter, Nov 7, 2016
  3. 2/3 gitk: remove closed file descriptors from $blobdifffdMarkus Hitter, Nov 7, 2016
  4. 3/3 gitk: clear array 'commitinfo' on reloadMarkus Hitter, Nov 7, 2016
  5. Jacob KellerNov 7, 2016
  6. Junio C HamanoNov 8, 2016
  7. Markus HitterNov 9, 2016
  8. Junio C HamanoNov 9, 2016
  9. Paul MackerrasDec 12, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.