gitk: Improve responsiveness while reading and layout out the graph
This restructures layoutmore so that it can take a time limit and do limited amounts of graph layout and graph optimization, and return 1 if it exceeded the time limit before finishing everything it could do. Also getcommitlines reads at most half a megabyte each time, to limit the time it spends parsing the commits to about a tenth of a second. Also got rid of the unused ncmupdate variable while I was at it. Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
parent
ceadfe90c6
commit
d1e46756d3
58
gitk
58
gitk
@ -17,13 +17,12 @@ proc gitdir {} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc start_rev_list {view} {
|
proc start_rev_list {view} {
|
||||||
global startmsecs nextupdate ncmupdate
|
global startmsecs nextupdate
|
||||||
global commfd leftover tclencoding datemode
|
global commfd leftover tclencoding datemode
|
||||||
global viewargs viewfiles commitidx
|
global viewargs viewfiles commitidx
|
||||||
|
|
||||||
set startmsecs [clock clicks -milliseconds]
|
set startmsecs [clock clicks -milliseconds]
|
||||||
set nextupdate [expr {$startmsecs + 100}]
|
set nextupdate [expr {$startmsecs + 100}]
|
||||||
set ncmupdate 1
|
|
||||||
set commitidx($view) 0
|
set commitidx($view) 0
|
||||||
set args $viewargs($view)
|
set args $viewargs($view)
|
||||||
if {$viewfiles($view) ne {}} {
|
if {$viewfiles($view) ne {}} {
|
||||||
@ -79,7 +78,7 @@ proc getcommitlines {fd view} {
|
|||||||
global parentlist childlist children curview hlview
|
global parentlist childlist children curview hlview
|
||||||
global vparentlist vchildlist vdisporder vcmitlisted
|
global vparentlist vchildlist vdisporder vcmitlisted
|
||||||
|
|
||||||
set stuff [read $fd]
|
set stuff [read $fd 500000]
|
||||||
if {$stuff == {}} {
|
if {$stuff == {}} {
|
||||||
if {![eof $fd]} return
|
if {![eof $fd]} return
|
||||||
global viewname
|
global viewname
|
||||||
@ -185,7 +184,7 @@ proc getcommitlines {fd view} {
|
|||||||
}
|
}
|
||||||
if {$gotsome} {
|
if {$gotsome} {
|
||||||
if {$view == $curview} {
|
if {$view == $curview} {
|
||||||
layoutmore
|
while {[layoutmore $nextupdate]} doupdate
|
||||||
} elseif {[info exists hlview] && $view == $hlview} {
|
} elseif {[info exists hlview] && $view == $hlview} {
|
||||||
vhighlightmore
|
vhighlightmore
|
||||||
}
|
}
|
||||||
@ -196,20 +195,13 @@ proc getcommitlines {fd view} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc doupdate {} {
|
proc doupdate {} {
|
||||||
global commfd nextupdate numcommits ncmupdate
|
global commfd nextupdate numcommits
|
||||||
|
|
||||||
foreach v [array names commfd] {
|
foreach v [array names commfd] {
|
||||||
fileevent $commfd($v) readable {}
|
fileevent $commfd($v) readable {}
|
||||||
}
|
}
|
||||||
update
|
update
|
||||||
set nextupdate [expr {[clock clicks -milliseconds] + 100}]
|
set nextupdate [expr {[clock clicks -milliseconds] + 100}]
|
||||||
if {$numcommits < 100} {
|
|
||||||
set ncmupdate [expr {$numcommits + 1}]
|
|
||||||
} elseif {$numcommits < 10000} {
|
|
||||||
set ncmupdate [expr {$numcommits + 10}]
|
|
||||||
} else {
|
|
||||||
set ncmupdate [expr {$numcommits + 100}]
|
|
||||||
}
|
|
||||||
foreach v [array names commfd] {
|
foreach v [array names commfd] {
|
||||||
set fd $commfd($v)
|
set fd $commfd($v)
|
||||||
fileevent $fd readable [list getcommitlines $fd $v]
|
fileevent $fd readable [list getcommitlines $fd $v]
|
||||||
@ -1697,7 +1689,7 @@ proc showview {n} {
|
|||||||
show_status "Reading commits..."
|
show_status "Reading commits..."
|
||||||
}
|
}
|
||||||
if {[info exists commfd($n)]} {
|
if {[info exists commfd($n)]} {
|
||||||
layoutmore
|
layoutmore {}
|
||||||
} else {
|
} else {
|
||||||
finishcommits
|
finishcommits
|
||||||
}
|
}
|
||||||
@ -2378,20 +2370,38 @@ proc visiblerows {} {
|
|||||||
return [list $r0 $r1]
|
return [list $r0 $r1]
|
||||||
}
|
}
|
||||||
|
|
||||||
proc layoutmore {} {
|
proc layoutmore {tmax} {
|
||||||
global rowlaidout rowoptim commitidx numcommits optim_delay
|
global rowlaidout rowoptim commitidx numcommits optim_delay
|
||||||
global uparrowlen curview
|
global uparrowlen curview
|
||||||
|
|
||||||
set row $rowlaidout
|
while {1} {
|
||||||
set rowlaidout [layoutrows $row $commitidx($curview) 0]
|
if {$rowoptim - $optim_delay > $numcommits} {
|
||||||
set orow [expr {$rowlaidout - $uparrowlen - 1}]
|
showstuff [expr {$rowoptim - $optim_delay}]
|
||||||
if {$orow > $rowoptim} {
|
} elseif {$rowlaidout - $uparrowlen - 1 > $rowoptim} {
|
||||||
optimize_rows $rowoptim 0 $orow
|
set nr [expr {$rowlaidout - $uparrowlen - 1 - $rowoptim}]
|
||||||
set rowoptim $orow
|
if {$nr > 100} {
|
||||||
}
|
set nr 100
|
||||||
set canshow [expr {$rowoptim - $optim_delay}]
|
}
|
||||||
if {$canshow > $numcommits} {
|
optimize_rows $rowoptim 0 [expr {$rowoptim + $nr}]
|
||||||
showstuff $canshow
|
incr rowoptim $nr
|
||||||
|
} elseif {$commitidx($curview) > $rowlaidout} {
|
||||||
|
set nr [expr {$commitidx($curview) - $rowlaidout}]
|
||||||
|
# may need to increase this threshold if uparrowlen or
|
||||||
|
# mingaplen are increased...
|
||||||
|
if {$nr > 150} {
|
||||||
|
set nr 150
|
||||||
|
}
|
||||||
|
set row $rowlaidout
|
||||||
|
set rowlaidout [layoutrows $row [expr {$row + $nr}] 0]
|
||||||
|
if {$rowlaidout == $row} {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
if {$tmax ne {} && [clock clicks -milliseconds] >= $tmax} {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user