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.
proc getcommits {rargs} {
global commits commfd phase canv mainfont env
proc getcommits {rargs} {
global commits commfd phase canv mainfont env
- global startmsecs nextupdate
+ global startmsecs nextupdate ncmupdate
global ctext maincursor textcursor leftover
# check that we can find a .git directory somewhere...
global ctext maincursor textcursor leftover
# check that we can find a .git directory somewhere...
set phase getcommits
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr $startmsecs + 100]
set phase getcommits
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr $startmsecs + 100]
if [catch {
set parse_args [concat --default HEAD $rargs]
set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
if [catch {
set parse_args [concat --default HEAD $rargs]
set parsed_args [split [eval exec git-rev-parse $parse_args] "\n"]
}
set leftover {}
fconfigure $commfd -blocking 0 -translation lf
}
set leftover {}
fconfigure $commfd -blocking 0 -translation lf
- fileevent $commfd readable "getcommitlines $commfd"
+ fileevent $commfd readable [list getcommitlines $commfd]
$canv delete all
$canv create text 3 3 -anchor nw -text "Reading commits..." \
-font $mainfont -tags textitems
$canv delete all
$canv create text 3 3 -anchor nw -text "Reading commits..." \
-font $mainfont -tags textitems
global commits parents cdate children nchildren
global commitlisted phase commitinfo nextupdate
global stopped redisplaying leftover
global commits parents cdate children nchildren
global commitlisted phase commitinfo nextupdate
global stopped redisplaying leftover
+ global numcommits ncmupdate
set stuff [read $commfd]
if {$stuff == {}} {
set stuff [read $commfd]
if {$stuff == {}} {
set commitlisted($id) 1
parsecommit $id $cmit 1
drawcommit $id
set commitlisted($id) 1
parsecommit $id $cmit 1
drawcommit $id
- if {[clock clicks -milliseconds] >= $nextupdate} {
+ if {[clock clicks -milliseconds] >= $nextupdate
+ && $numcommits >= $ncmupdate + 100} {
+ set ncmupdate $numcommits
}
while {$redisplaying} {
set redisplaying 0
}
while {$redisplaying} {
set redisplaying 0
foreach id $commits {
drawcommit $id
if {$stopped} break
foreach id $commits {
drawcommit $id
if {$stopped} break
- if {[clock clicks -milliseconds] >= $nextupdate} {
+ if {[clock clicks -milliseconds] >= $nextupdate
+ && $numcommits >= $ncmupdate + 100} {
+ set ncmupdate $numcommits
incr nextupdate 100
fileevent $commfd readable {}
update
incr nextupdate 100
fileevent $commfd readable {}
update
- fileevent $commfd readable "getcommitlines $commfd"
+ fileevent $commfd readable [list getcommitlines $commfd]
proc drawcommit {id} {
global phase todo nchildren datemode nextupdate
proc drawcommit {id} {
global phase todo nchildren datemode nextupdate
+ global startcommits numcommits ncmupdate
if {$phase != "incrdraw"} {
set phase incrdraw
if {$phase != "incrdraw"} {
set phase incrdraw
if {![info exists commitlisted($id)]} {
break
}
if {![info exists commitlisted($id)]} {
break
}
- if {[clock clicks -milliseconds] >= $nextupdate} {
+ if {[clock clicks -milliseconds] >= $nextupdate
+ && $numcommits >= $ncmupdate} {
+ set ncmupdate $numcommits
- global nextupdate startmsecs startcommits todo
+ global nextupdate startmsecs startcommits todo ncmupdate
if {$startcommits == {}} return
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr $startmsecs + 100]
if {$startcommits == {}} return
set startmsecs [clock clicks -milliseconds]
set nextupdate [expr $startmsecs + 100]
initgraph
set todo [lindex $startcommits 0]
drawrest 0 1
initgraph
set todo [lindex $startcommits 0]
drawrest 0 1
proc drawrest {level startix} {
global phase stopped redisplaying selectedline
global datemode currentparents todo
proc drawrest {level startix} {
global phase stopped redisplaying selectedline
global datemode currentparents todo
+ global numcommits ncmupdate
global nextupdate startmsecs startcommits idline
if {$level >= 0} {
global nextupdate startmsecs startcommits idline
if {$level >= 0} {
if {$level < 0} break
drawslants $level
}
if {$level < 0} break
drawslants $level
}
- if {[clock clicks -milliseconds] >= $nextupdate} {
+ if {[clock clicks -milliseconds] >= $nextupdate
+ && $numcommits >= $ncmupdate + 100} {
update
incr nextupdate 100
update
incr nextupdate 100
+ set ncmupdate $numcommits