Tk Source Code

View Ticket
Login
Ticket UUID: 220337
Title: prowish not as fast as tcl8.0p2
Type: Bug Version: obsolete: 8.0.3
Submitter: welch Created on: 2000-10-31 23:14:48
Subsystem: 85. Win Build Assigned To: nobody
Priority: 2 Severity:
Status: Closed Last Modified: 2001-04-25 23:49:56
Resolution: Fixed Closed By: dgp
    Closed on: 2001-04-25 16:49:56
Description:
OriginalBugID: 212 Bug
Version: 1.0b4
SubmitDate: '1998-07-23'
LastModified: '1999-12-14'
Severity: LOW
Status: Fix/AA
Submitter: hershey
ChangedBy: hobbs
OS: All Windows
OSVersion: NA
Machine: NA
FixedDate: '1999-12-14'
FixedInVersion: 1.3


I discovered that standard WISH80.EXE runs my code at a good speed, 
however running PROWISH.EXE slowed my program by about 5 times, 
compiling it with PROCOMP and running "PROWISH source.TBC" was 
same as uncompiled.


(ems 8/28/98) set the OS field to "All Windows", this is not a generic problem

(ems 8/28/98) There is definitely a performance degradation in protclsh, although not necessarily 5 times slower (other users have reported twice as slow, and that is consistent with a quick-and-dirty bekchmark I did). The reason is that we switched to VC++ 5.0 from Borland, and decided not to tighten the optimization flags for fear that the optimizer would generate bad code. I ran the following test script on a number of platforms, see results below:

proc f {i} {
    set x [expr {$i * $i}]
    return $x
}
puts [time {f 2} 50000]

8.0.3 with default VC++ flags  :                         12 microseconds per iteration
8.0.3 with maximum optimization (-O2) :         7 microseconds per iteration
8.0p2 with default VC++ flags :                        10 microseconds per iteration
8.0p2 with Borland compiler  :                            6 microseconds per iteration
tclpro  :                                                                   12 microseconds per iteration
tclpro with maximum optimization (-O2)   :     7 microseconds per iteration

(ems 8/28/98) Also, compiling a .tcl script into .tbc won't change runtime performance: the .tbc file contains the same bytecodes that the .tcl file would generate. There may be an improvement in loading performance if the .tbc file is smaller enough than the .tcl file that I/O gains overshadow the added expense of decoding the .tbc file.

(pat 9/2/98) Under Windows, Tcl code executed by the Tclpro shells (protclsh80.exe and
prowish80.exe) will run slower than if it were executed in 8.0p2 shells.

This is because TclPro switched from Borland to VC++ as the compiler of
choice with the Tcl/Tk builds. The optimization flags for VC++ were left at a
somewhat loose level, because we were worried that more aggressive optimization
would generate bad codes, and there wasn't enough time to do extensive
testing to make sure that the optimizer behaved.

As a consequence, the TclPro interpreters are slower than 8.0p2. Note that
protclsh80.exe and prowish80.exe are NOT slower than 8.0.3 interpreters built
with VC++ and the makefile.vc in the win directories. They will be slower than
8.0.3 interpreters built with -O2, however; for example, if someone creates
a DevStudio project, sets it to "Maximize Speed", generates the DLL and the
EXE, those interpreters will be faster than ours.
--
work-arounds:

This is a possible workaround:

1) rebuild the Tcl 8.0.3 DLL from the source distribution, using VC++ 5.0
   with optimization flags set to -O2. For example, this can be done from
   the Developer Studio IDE by selecting the C/C++ tab in "Settings", the
   "Optimizations" category, and the "Maximize Speed" drop-down choice.

2) replace tcl80.dll in win32-ix86/bin with the one you built in step 1.
   Don't forget to make a copy of the original in case you want to switch
   back.

The TclPro-generated tcl80.dll was built from the same distribution as the
8.0.3 tcl80.dll, so replacing it should be OK. The unknown here is how well
the code optimizer in VC++ works, in particular will it generate bad code.
--
More recent versions of Tcl (and TclPro) use -O2, as well as newer
versions of VC++. 
-- 12/14/1999 hobbs