Skip to contentSkip to conversation

gitk management of git diff-tree processes

DISCUSSION David Holmer 1 participant 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I find that if I am in gitk browsing through commits, gitk seems to be spawning a git diff-tree process in order to display the changes and patch file list in the bottom panes.

I have a certain commit that adds a very large amount of data to my repository (1.2 GB). Understandably, the git diff-tree process that tries to display the changes in this commit takes a VERY long time to run (e.g. churns indefinitely).

The issue is that I find that if I simply browse past this commit (e.g. using up/down arrows), gitk starts up a git diff-tree process and leaves it running. As many times as I pass the commit (e.g. while looking at changes before and after this commit), I end up with multiple processes all running and my CPUs quickly go to 100%. Furthermore, even if I exit gitk, all the git diff-tree processes keep running unless I manually kill them.

Perhaps gitk could kill the git diff-tree process it spawns if its output is no longer needed (e.g. user browses to a different commit, or gitk exits).

Thank you,
David

$ ps -aF
UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
david    23635     1 18 88365 102892  0 10:49 pts/1    00:01:11 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23640     1 18 88368 102908  1 10:49 pts/1    00:01:10 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23644     1 16 88368 102904  0 10:49 pts/1    00:01:04 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23646     1 16 88367 102916  0 10:49 pts/1    00:01:04 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23652     1 17 88365 102892  1 10:49 pts/1    00:01:07 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23656     1 17 88368 102920  1 10:49 pts/1    00:01:06 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23660     1 16 88369 102932  0 10:49 pts/1    00:01:03 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23664     1 16 88368 102908  0 10:49 pts/1    00:01:03 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23670     1 16 88368 102904  1 10:49 pts/1    00:01:03 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23680     1 17 88365 102896  1 10:49 pts/1    00:01:05 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23851 10444  0   692  1032   0 10:56 pts/1    00:00:00 ps -aF
$ git version
git version 1.6.4.4
Signature · 8 lines
David G. Holmer, Ph.D.
[email protected]
CTO and Co-Founder
Persistent Systems, LLC
www.persistentsystems.com
Office: 212-561-5895
Mobile: 650-533-4964
Fax: 212-202-3625
#1 lore raw
Quoted 38 lines · David Holmer

I find that if I am in gitk browsing through commits, gitk seems to be spawning a git diff-tree process in order to display the changes and patch file list in the bottom panes.

I have a certain commit that adds a very large amount of data to my repository (1.2 GB). Understandably, the git diff-tree process that tries to display the changes in this commit takes a VERY long time to run (e.g. churns indefinitely).

The issue is that I find that if I simply browse past this commit (e.g. using up/down arrows), gitk starts up a git diff-tree process and leaves it running. As many times as I pass the commit (e.g. while looking at changes before and after this commit), I end up with multiple processes all running and my CPUs quickly go to 100%. Furthermore, even if I exit gitk, all the git diff-tree processes keep running unless I manually kill them.

Perhaps gitk could kill the git diff-tree process it spawns if its output is no longer needed (e.g. user browses to a different commit, or gitk exits).

Thank you,
David

$ ps -aF
UID        PID  PPID  C    SZ   RSS PSR STIME TTY          TIME CMD
david    23635     1 18 88365 102892  0 10:49 pts/1    00:01:11 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23640     1 18 88368 102908  1 10:49 pts/1    00:01:10 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23644     1 16 88368 102904  0 10:49 pts/1    00:01:04 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23646     1 16 88367 102916  0 10:49 pts/1    00:01:04 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23652     1 17 88365 102892  1 10:49 pts/1    00:01:07 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23656     1 17 88368 102920  1 10:49 pts/1    00:01:06 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23660     1 16 88369 102932  0 10:49 pts/1    00:01:03 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23664     1 16 88368 102908  0 10:49 pts/1    00:01:03 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23670     1 16 88368 102904  1 10:49 pts/1    00:01:03 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23680     1 17 88365 102896  1 10:49 pts/1    00:01:05 git diff-tree -r -p --textconv -C --cc --no-commit-id -U3 8df50645c4cadf26dc951540e0c713b0826247b8
david    23851 10444  0   692  1032   0 10:56 pts/1    00:00:00 ps -aF
Quoted 3 lines
$ git version
git version 1.6.4.4

Looking at the code of gitk, I believe the git diff-tree process is spawned by proc getblobdiffs (gitk-git/gitk:7322). It sets up a command that matches all the arguments I see in the above ps -aF listing (gitk-git/gitk:7335):

set cmd [diffcmd $ids "-p $textconv -C --cc --no-commit-id -U $diffcontext"]

It then seems to setup this command to be run and the output processed via proc filerun (gitk-git/gitk:7352):

filerun $bdf [list getblobdiffline $bdf $diffids]

I am not very familiar with TCL. Is there a standard/correct way to pre-maturely halt this filerun processing? It seems to use the fileevent to know when there is more data to process.

A Google search turned up a way to get the PID from $bfd and said that on unix systems you could run a kill, but that TCL had no built in kill mechanism. This seems a bit hackish/non-cross platform. Is there a better mechanism? Would something like closing the file descriptor cause the filerun processing to finish and the git diff-tree to terminate with a broken pipe?

Thank you,
David

Signature · 8 lines
David G. Holmer, Ph.D.
[email protected]
CTO and Co-Founder
Persistent Systems, LLC
www.persistentsystems.com
Office: 212-561-5895
Mobile: 650-533-4964
Fax: 212-202-3625