Subject: Re: 8.1 slower then 8.0??? - DN [1]
Andreas Kupries <a.kupries@westend.com> - 14 May 1999 - comp.lang.tcl
Scott Stanton <scott.stanton@Scriptics.com> writes:
> John McLaughlin wrote:
>> I think the key word in all of the comments is 'expect', there are
>> certainly no guarantees or promises but there were _expectations_
>> that it would be >= 8.0 speed and those expectations were not
>> managed (to the best of my knowledge) -- something along the lines
>> of 'Tcl 8.1 is under some situations slower than Tcl 8.0 so if
>> performance is critical stick with Tcl 8.0' would have helped
>> manage expectations. (but of course that would have launched a
>> similar series of discussions..)
> To be fair, some things in 8.1 are faster than 8.0 and many things
> are the same. For example, execution of global code is faster in
> 8.1 because we skip compilation in cases where the code will only be
> invoked once.
I believe that this is only true if the global code does not contain
(nested) loops. For the top-level parser the loop body is a single
word which will be reparsed into tokens for every iteration (*).
Bob Techentin <techentin.robert@mayo.edu> wrote some time ago
(in message <36F7DE83.B04E53AE@mayo.edu>,
send at Tue, 23 Mar 1999 12:33:39 -0600):
| I've also noticed that in-line script code does not appear to
| get byte-compiled. It is faster to put initialization code
| into procs. Try this example:
|
| set t1 [clock clicks]
| for {set i 0} {$i<10000} {incr i} {lappend a $i}
|
| set t2 [clock clicks]
| proc initme {} {
| global b
| for {set i 0} {$i<10000} {incr i} {lappend b $i}
| }
| initme
| set t3 [clock clicks]
|
| puts "inline code took [expr $t2-$t1]"
| puts "proc code took [expr $t3-$t2]"
Unfortunately he did not mention the version he used. I tried the code
for 8.0.5 and 8.1 (Linux 2.0.29, P133), here are the results
patchlevel = 8.0.5
inline code took 566287
proc code took 356601
patchlevel = 8.1.0
inline code took 910684
proc code took 320657
In both versions the proc is faster, but for 8.1 the difference is
much more significant.
(*) I think a little explanation is in order: In Tcl 8.0.x every code,
including eval'd and source'd, is compiled into bytecode and then
executed. Tcl 8.1.x on the other hand split the compiler into a parser
frontend and a compiler backend, the structure to exchange information
between them is a 'Tcl_Token' array. This was used to compile only
procedures, but code at the global level (in source, eval, ...) is
just parsed into tokens, which are then interpreted immediately in a
new procedure, without resorting to bytecode.
+---------------------------+
| parser |
+---------------------------+
| Tcl_Token array |
+--------+ +-----------+
| token | | bytecode |
| interp | | generator |
+--------+ +-----------+
| bytecode object
+-----------+
| bytecode |
| interp |
+-----------+
--
Sincerely,
Andreas Kupries <a.kupries@westend.com>
<http://www.westend.com/~kupries/>
-------------------------------------------------------------------------------
Last modified
1999-09-27
1999-09-27
(195.108.246.50)
Note: you are looking at
the snapshot of an old wiki
- much of this information
is likely to be very outdated
