Skip to content
Tcl Source Code View Ticket
Login

View Ticket

tcl8.0p2 is 10x faster than tcl8.0.3: performance bug when

Closed / Fixed218487ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:01:09
OriginalBugID: 702 Bug
Version: 8.0.3
SubmitDate: '1998-10-09'
LastModified: '2000-02-05'
Severity: SER
Status: Released
Submitter: admin
ChangedBy: hobbs
OS: All
OSVersion: NA
Machine: NA
FixedDate: '2000-02-05'
FixedInVersion: 8.2
ClosedDate: '2000-10-25'


I have done some further testing related to this performance problem.

I have attempted to remove code and narrow down the problem - so far I have
disconvered that one procedure in particular is taking ages (like 10-20
times than before):
See below... proc get_raw_token

I have also downloaded the source release and compiled this on my Linux box,
running the same application it is also extremely slow compared to the 8.0p2
release!

# include special handling for tokens and separators
# if processing ALPHA then get separator -> end of token
# if processing NUMBER then get separator -> end of token
# if processing SEPARATOR then test for next char?? only <= >= <> != ??
# note: this processing is handled semi-automatically by "string
wordstart/end"

proc get_raw_token {} {
    global file_source file_source_pos file_source_line

    while 1 {
 set start [string wordstart $file_source $file_source_pos]
 set end [expr {[string wordend $file_source $file_source_pos] - 1}]

 # null? assume end of file
 if {$end < $file_source_pos} { return "//eof" }

 set file_source_pos [expr {$end + 1}]
 set token [string range $file_source $start $end]

 # comments? search until end of the line
 if {$token == "/"} {
     if {[string range $file_source $file_source_pos $file_source_pos] ==
"/"} {
  while {[string range $file_source $file_source_pos $file_source_pos] >= "
"} {
      incr file_source_pos
  }
     }
 } elseif {$token == "'"} {
     while {[string range $file_source $file_source_pos $file_source_pos] !=
"'"} {
  incr file_source_pos
     }
     # skip final quote character
     set end $file_source_pos
     incr file_source_pos
     # return string, including quote characters
     return [string range $file_source $start $end]
 } elseif {$token == "\""} {
     while {[string range $file_source $file_source_pos $file_source_pos] !=
"\""} {
  incr file_source_pos
     }
     # skip final quote character
     set end $file_source_pos
     incr file_source_pos
     # return string, including quote characters
     return [string range $file_source $start $end]
 } elseif {$token == "\n"} { incr file_source_line
 } elseif {$token > " "} { return $token }
    }
}

Peter Campbell wrote:

> I have upgraded from Tcl8.0p2 on Win95 to 8.0.3 - downloaded the binary
> distribution for both.
>
> My application which is a compiler/translator now runs 10-20 times
> slower than before.
>
> I had also run my application on Linux using Tcl7.6 and on Linux using
> itcl3.0a1 with Tcl8.0. The performance was good, I have not yet tried my
> application on Linux using the new Tcl8.0.3.
>
> Has anybody else experienced any performance problems?
> I have reported this problem to Scriptics as it also effected their
> "prowish" program.
>
> Does anyone involved with the source code of Tcl know what has changed
> to effect performance to this extreme from 8.0p2 to 8.0.3?
>
> I thought it may be to do with source files being re-"compiled"
> constantly or something??
> I do not use any extensions as yet, the program uses file access -
> mainly reading small (5-10k) files into a string then processing them
> using the string commands.
>
> HELP...


The problem was due to an optimization that was removed because it
wasn't 100% correct, which was later reinstated with full correctness
(at least in 8.2, may be earlier).  All the user has to do is:

    while {1}

instead of

    while 1

to get the speed back.  This is pedantically correct, but as I said,
the optimization was also reinstated later.  The algorithm itself
could be significantly improved. 
-- 02/05/2000 hobbs
welch Closed ticket [218487ffff]. [History diff]2000-10-26 08:23:17
Log in (anonymous is fine) to add a comment.