git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH (GITK) 0/3] Avoid runaway processes in gitk
@ 2008-07-18  5:44 Alexander Gavrilov
  2008-07-18  5:45 ` [PATCH (GITK) 1/3] gitk: Kill back-end processes on window close Alexander Gavrilov
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Gavrilov @ 2008-07-18  5:44 UTC (permalink / raw)
  To: git; +Cc: Paul Mackerras

As in the 'git gui blame' case, gitk back-end processes can sometimes
run for a while without producing any output, e.g. diff-files on a slow
filesystem.

These patches make gitk explicitly kill its back-end processes.

Alexander Gavrilov (3):
      gitk: Kill back-end processes on window close.
      gitk: Register diff-files & diff-index in commfd, to ensure kill.
      gitk: On Windows use a Cygwin-specific flag for kill.

 gitk |   79 ++++++++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 53 insertions(+), 26 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH (GITK) 1/3] gitk: Kill back-end processes on window close.
  2008-07-18  5:44 [PATCH (GITK) 0/3] Avoid runaway processes in gitk Alexander Gavrilov
@ 2008-07-18  5:45 ` Alexander Gavrilov
  2008-07-18  5:46   ` [PATCH (GITK) 2/3] gitk: Register diff-files & diff-index in commfd, to ensure kill Alexander Gavrilov
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Gavrilov @ 2008-07-18  5:45 UTC (permalink / raw)
  To: git; +Cc: Paul Mackerras

When collecting commits for a rarely changed, or recently
created file or directory, rev-list may work for a noticeable
period of time without producing any output. Such processes
don't receive SIGPIPE for a while after gitk is closed, thus
becoming runaway CPU hogs.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
 gitk |   35 +++++++++++++++++++++++++----------
 1 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/gitk b/gitk
index fddcb45..29d79d6 100755
--- a/gitk
+++ b/gitk
@@ -375,19 +375,33 @@ proc start_rev_list {view} {
     return 1
 }
 
+proc stop_instance {inst} {
+    global commfd leftover
+
+    set fd $commfd($inst)
+    catch {
+	set pid [pid $fd]
+	exec kill $pid
+    }
+    catch {close $fd}
+    nukefile $fd
+    unset commfd($inst)
+    unset leftover($inst)
+}
+
+proc stop_backends {} {
+    global commfd
+
+    foreach inst [array names commfd] {
+	stop_instance $inst
+    }
+}
+
 proc stop_rev_list {view} {
-    global commfd viewinstances leftover
+    global viewinstances
 
     foreach inst $viewinstances($view) {
-	set fd $commfd($inst)
-	catch {
-	    set pid [pid $fd]
-	    exec kill $pid
-	}
-	catch {close $fd}
-	nukefile $fd
-	unset commfd($inst)
-	unset leftover($inst)
+	stop_instance $inst
     }
     set viewinstances($view) {}
 }
@@ -2103,6 +2117,7 @@ proc makewindow {} {
     bind . <$M1B-minus> {incrfont -1}
     bind . <$M1B-KP_Subtract> {incrfont -1}
     wm protocol . WM_DELETE_WINDOW doquit
+    bind . <Destroy> {stop_backends}
     bind . <Button-1> "click %W"
     bind $fstring <Key-Return> {dofind 1 1}
     bind $sha1entry <Key-Return> gotocommit
-- 
1.5.6.2.39.gd084

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH (GITK) 2/3] gitk: Register diff-files & diff-index in commfd, to ensure kill.
  2008-07-18  5:45 ` [PATCH (GITK) 1/3] gitk: Kill back-end processes on window close Alexander Gavrilov
@ 2008-07-18  5:46   ` Alexander Gavrilov
  2008-07-18  5:47     ` [PATCH (GITK) 3/3] gitk: On Windows use a Cygwin-specific flag for kill Alexander Gavrilov
  0 siblings, 1 reply; 4+ messages in thread
From: Alexander Gavrilov @ 2008-07-18  5:46 UTC (permalink / raw)
  To: git; +Cc: Paul Mackerras

Local change analysis can take a noticeable amount of time on large
file sets, and produce no output if there are no changes. Register
the back-ends in commfd, so that they get properly killed on window
close.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
 gitk |   39 +++++++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/gitk b/gitk
index 29d79d6..b523c98 100755
--- a/gitk
+++ b/gitk
@@ -90,6 +90,15 @@ proc dorunq {} {
     }
 }
 
+proc reg_instance {fd} {
+    global commfd leftover loginstance
+
+    set i [incr loginstance]
+    set commfd($i) $fd
+    set leftover($i) {}
+    return $i
+}
+
 proc unmerged_files {files} {
     global nr_unmerged
 
@@ -294,10 +303,10 @@ proc parseviewrevs {view revs} {
 # Start off a git log process and arrange to read its output
 proc start_rev_list {view} {
     global startmsecs commitidx viewcomplete curview
-    global commfd leftover tclencoding
+    global tclencoding
     global viewargs viewargscmd viewfiles vfilelimit
     global showlocalchanges commitinterest
-    global viewactive loginstance viewinstances vmergeonly
+    global viewactive viewinstances vmergeonly
     global pending_select mainheadid
     global vcanopt vflags vrevs vorigargs
 
@@ -354,10 +363,8 @@ proc start_rev_list {view} {
 	error_popup "[mc "Error executing git log:"] $err"
 	return 0
     }
-    set i [incr loginstance]
+    set i [reg_instance $fd]
     set viewinstances($view) [list $i]
-    set commfd($i) $fd
-    set leftover($i) {}
     if {$showlocalchanges && $mainheadid ne {}} {
 	lappend commitinterest($mainheadid) {dodiffindex}
     }
@@ -420,8 +427,8 @@ proc getcommits {} {
 
 proc updatecommits {} {
     global curview vcanopt vorigargs vfilelimit viewinstances
-    global viewactive viewcomplete loginstance tclencoding
-    global startmsecs commfd showneartags showlocalchanges leftover
+    global viewactive viewcomplete tclencoding
+    global startmsecs showneartags showlocalchanges
     global mainheadid pending_select
     global isworktree
     global varcid vposids vnegids vflags vrevs
@@ -482,10 +489,8 @@ proc updatecommits {} {
     if {$viewactive($view) == 0} {
 	set startmsecs [clock clicks -milliseconds]
     }
-    set i [incr loginstance]
+    set i [reg_instance $fd]
     lappend viewinstances($view) $i
-    set commfd($i) $fd
-    set leftover($i) {}
     fconfigure $fd -blocking 0 -translation lf -eofchar {}
     if {$tclencoding != {}} {
 	fconfigure $fd -encoding $tclencoding
@@ -4063,10 +4068,11 @@ proc dodiffindex {} {
     incr lserial
     set fd [open "|git diff-index --cached HEAD" r]
     fconfigure $fd -blocking 0
-    filerun $fd [list readdiffindex $fd $lserial]
+    set i [reg_instance $fd]
+    filerun $fd [list readdiffindex $fd $lserial $i]
 }
 
-proc readdiffindex {fd serial} {
+proc readdiffindex {fd serial inst} {
     global mainheadid nullid nullid2 curview commitinfo commitdata lserial
 
     set isdiff 1
@@ -4077,7 +4083,7 @@ proc readdiffindex {fd serial} {
 	set isdiff 0
     }
     # we only need to see one line and we don't really care what it says...
-    close $fd
+    stop_instance $inst
 
     if {$serial != $lserial} {
 	return 0
@@ -4086,7 +4092,8 @@ proc readdiffindex {fd serial} {
     # now see if there are any local changes not checked in to the index
     set fd [open "|git diff-files" r]
     fconfigure $fd -blocking 0
-    filerun $fd [list readdifffiles $fd $serial]
+    set i [reg_instance $fd]
+    filerun $fd [list readdifffiles $fd $serial $i]
 
     if {$isdiff && ![commitinview $nullid2 $curview]} {
 	# add the line for the changes in the index to the graph
@@ -4103,7 +4110,7 @@ proc readdiffindex {fd serial} {
     return 0
 }
 
-proc readdifffiles {fd serial} {
+proc readdifffiles {fd serial inst} {
     global mainheadid nullid nullid2 curview
     global commitinfo commitdata lserial
 
@@ -4115,7 +4122,7 @@ proc readdifffiles {fd serial} {
 	set isdiff 0
     }
     # we only need to see one line and we don't really care what it says...
-    close $fd
+    stop_instance $inst
 
     if {$serial != $lserial} {
 	return 0
-- 
1.5.6.2.39.gd084

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH (GITK) 3/3] gitk: On Windows use a Cygwin-specific flag for kill.
  2008-07-18  5:46   ` [PATCH (GITK) 2/3] gitk: Register diff-files & diff-index in commfd, to ensure kill Alexander Gavrilov
@ 2008-07-18  5:47     ` Alexander Gavrilov
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Gavrilov @ 2008-07-18  5:47 UTC (permalink / raw)
  To: git; +Cc: Paul Mackerras

MSysGit compiles git binaries as native Windows executables,
so they cannot be killed unless a special flag is specified.

This flag is implemented by the Cygwin version of kill,
which is also included in MSysGit.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
 gitk |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/gitk b/gitk
index b523c98..d7fea26 100755
--- a/gitk
+++ b/gitk
@@ -388,7 +388,12 @@ proc stop_instance {inst} {
     set fd $commfd($inst)
     catch {
 	set pid [pid $fd]
-	exec kill $pid
+
+	if {$::tcl_platform(platform) eq {windows}} {
+	    exec kill -f $pid
+	} else {
+	    exec kill $pid
+	}
     }
     catch {close $fd}
     nukefile $fd
-- 
1.5.6.2.39.gd084

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-07-18  5:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-18  5:44 [PATCH (GITK) 0/3] Avoid runaway processes in gitk Alexander Gavrilov
2008-07-18  5:45 ` [PATCH (GITK) 1/3] gitk: Kill back-end processes on window close Alexander Gavrilov
2008-07-18  5:46   ` [PATCH (GITK) 2/3] gitk: Register diff-files & diff-index in commfd, to ensure kill Alexander Gavrilov
2008-07-18  5:47     ` [PATCH (GITK) 3/3] gitk: On Windows use a Cygwin-specific flag for kill Alexander Gavrilov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).