提交 466e4fdd 编写于 作者: P Paul Mackerras

Only do an update every 100 commits when drawing the graph.

On a large repository with > 60,000 commits, each call to the Tk
update primitive (which gives Tk a chance to respond to events and
redraw the screen) was taking up to 0.2 seconds.  Because the logic
was to call update after drawing a commit if 0.1 seconds had passed
since the last update call, we were calling it for every commit,
which was slowing us down enormously.  Now we also require that we
have drawn 100 commits since the last update (as well as it being
at least 0.1 seconds since the last update).  Drawing 100 commits
takes around 0.1 - 0.2 seconds (even in this large repo) on my G5.
上级 b1ba39e7
...@@ -18,7 +18,7 @@ proc gitdir {} { ...@@ -18,7 +18,7 @@ proc gitdir {} {
proc getcommits {rargs} { proc getcommits {rargs} {
global commits commfd phase canv mainfont env global commits commfd phase canv mainfont env
global startmsecs nextupdate global startmsecs nextupdate ncmupdate
global ctext maincursor textcursor leftover global ctext maincursor textcursor leftover
# check that we can find a .git directory somewhere... # check that we can find a .git directory somewhere...
...@@ -31,6 +31,7 @@ proc getcommits {rargs} { ...@@ -31,6 +31,7 @@ proc getcommits {rargs} {
set phase getcommits set phase getcommits
set startmsecs [clock clicks -milliseconds] set startmsecs [clock clicks -milliseconds]
set nextupdate [expr $startmsecs + 100] set nextupdate [expr $startmsecs + 100]
set ncmupdate 0
if [catch { if [catch {
set parse_args [concat --default HEAD $rargs] set parse_args [concat --default HEAD $rargs]
set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"] set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
...@@ -49,7 +50,7 @@ proc getcommits {rargs} { ...@@ -49,7 +50,7 @@ proc getcommits {rargs} {
} }
set leftover {} set leftover {}
fconfigure $commfd -blocking 0 -translation lf fconfigure $commfd -blocking 0 -translation lf
fileevent $commfd readable "getcommitlines $commfd" fileevent $commfd readable [list getcommitlines $commfd]
$canv delete all $canv delete all
$canv create text 3 3 -anchor nw -text "Reading commits..." \ $canv create text 3 3 -anchor nw -text "Reading commits..." \
-font $mainfont -tags textitems -font $mainfont -tags textitems
...@@ -61,6 +62,7 @@ proc getcommitlines {commfd} { ...@@ -61,6 +62,7 @@ proc getcommitlines {commfd} {
global commits parents cdate children nchildren global commits parents cdate children nchildren
global commitlisted phase commitinfo nextupdate global commitlisted phase commitinfo nextupdate
global stopped redisplaying leftover global stopped redisplaying leftover
global numcommits ncmupdate
set stuff [read $commfd] set stuff [read $commfd]
if {$stuff == {}} { if {$stuff == {}} {
...@@ -108,8 +110,10 @@ to allow selection of commits to be displayed.)} ...@@ -108,8 +110,10 @@ to allow selection of commits to be displayed.)}
set commitlisted($id) 1 set commitlisted($id) 1
parsecommit $id $cmit 1 parsecommit $id $cmit 1
drawcommit $id drawcommit $id
if {[clock clicks -milliseconds] >= $nextupdate} { if {[clock clicks -milliseconds] >= $nextupdate
&& $numcommits >= $ncmupdate + 100} {
doupdate doupdate
set ncmupdate $numcommits
} }
while {$redisplaying} { while {$redisplaying} {
set redisplaying 0 set redisplaying 0
...@@ -119,8 +123,10 @@ to allow selection of commits to be displayed.)} ...@@ -119,8 +123,10 @@ to allow selection of commits to be displayed.)}
foreach id $commits { foreach id $commits {
drawcommit $id drawcommit $id
if {$stopped} break if {$stopped} break
if {[clock clicks -milliseconds] >= $nextupdate} { if {[clock clicks -milliseconds] >= $nextupdate
&& $numcommits >= $ncmupdate + 100} {
doupdate doupdate
set ncmupdate $numcommits
} }
} }
} }
...@@ -134,7 +140,7 @@ proc doupdate {} { ...@@ -134,7 +140,7 @@ proc doupdate {} {
incr nextupdate 100 incr nextupdate 100
fileevent $commfd readable {} fileevent $commfd readable {}
update update
fileevent $commfd readable "getcommitlines $commfd" fileevent $commfd readable [list getcommitlines $commfd]
} }
proc readcommit {id} { proc readcommit {id} {
...@@ -1090,7 +1096,7 @@ proc decidenext {{noread 0}} { ...@@ -1090,7 +1096,7 @@ proc decidenext {{noread 0}} {
proc drawcommit {id} { proc drawcommit {id} {
global phase todo nchildren datemode nextupdate global phase todo nchildren datemode nextupdate
global startcommits global startcommits numcommits ncmupdate
if {$phase != "incrdraw"} { if {$phase != "incrdraw"} {
set phase incrdraw set phase incrdraw
...@@ -1119,8 +1125,10 @@ proc drawcommit {id} { ...@@ -1119,8 +1125,10 @@ proc drawcommit {id} {
if {![info exists commitlisted($id)]} { if {![info exists commitlisted($id)]} {
break break
} }
if {[clock clicks -milliseconds] >= $nextupdate} { if {[clock clicks -milliseconds] >= $nextupdate
&& $numcommits >= $ncmupdate} {
doupdate doupdate
set ncmupdate $numcommits
if {$stopped} break if {$stopped} break
} }
} }
...@@ -1158,11 +1166,12 @@ proc settextcursor {c} { ...@@ -1158,11 +1166,12 @@ proc settextcursor {c} {
} }
proc drawgraph {} { proc drawgraph {} {
global nextupdate startmsecs startcommits todo global nextupdate startmsecs startcommits todo ncmupdate
if {$startcommits == {}} return if {$startcommits == {}} return
set startmsecs [clock clicks -milliseconds] set startmsecs [clock clicks -milliseconds]
set nextupdate [expr $startmsecs + 100] set nextupdate [expr $startmsecs + 100]
set ncmupdate 0
initgraph initgraph
set todo [lindex $startcommits 0] set todo [lindex $startcommits 0]
drawrest 0 1 drawrest 0 1
...@@ -1171,7 +1180,7 @@ proc drawgraph {} { ...@@ -1171,7 +1180,7 @@ proc drawgraph {} {
proc drawrest {level startix} { proc drawrest {level startix} {
global phase stopped redisplaying selectedline global phase stopped redisplaying selectedline
global datemode currentparents todo global datemode currentparents todo
global numcommits global numcommits ncmupdate
global nextupdate startmsecs startcommits idline global nextupdate startmsecs startcommits idline
if {$level >= 0} { if {$level >= 0} {
...@@ -1200,9 +1209,11 @@ proc drawrest {level startix} { ...@@ -1200,9 +1209,11 @@ proc drawrest {level startix} {
if {$level < 0} break if {$level < 0} break
drawslants $level drawslants $level
} }
if {[clock clicks -milliseconds] >= $nextupdate} { if {[clock clicks -milliseconds] >= $nextupdate
&& $numcommits >= $ncmupdate + 100} {
update update
incr nextupdate 100 incr nextupdate 100
set ncmupdate $numcommits
} }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册