Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-07-13
09:20 • Closed ticket [1586292fff]: threaded build too slow? plus 6 other changes artifact: 5c43c6c7b1 user: sf-robot
2008-06-28
21:06 • Pending ticket [1586292fff]. artifact: 86735f2b71 user: msofer
2008-01-14
07:31 • Ticket [1586292fff]: 4 changes artifact: 47021189b9 user: hobbs
2008-01-12
20:13 • Ticket [1586292fff]: 4 changes artifact: 623268e58b user: msofer
2006-10-29
09:37 • Ticket [1586292fff]: 4 changes artifact: 200fed948d user: mistachkin
01:33 • Ticket [1586292fff]: 4 changes artifact: 4255d51d6f user: msofer
00:08 • Ticket [1586292fff]: 4 changes artifact: 6891f8eb63 user: msofer
00:01 • Ticket [1586292fff]: 4 changes artifact: bb35ac305b user: msofer
2006-10-28
23:21 • Ticket [1586292fff]: 4 changes artifact: ff06c4b418 user: msofer
16:00 • New ticket [1586292fff]. artifact: 433d32bf07 user: msofer

threaded build too slow?

Closed / Fixed1586292fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 18 years ago
Descriptionplain2006-10-28 16:00:13
For reasons that are not important here, I timed the
speed of proc and ensemble calls in current HEAD. The
threaded build is *much* slower (1.75x). 

The script at /tmp/test is

   proc a {x y} {set x 1}
   namespace ensemble create -command ::w -map {a a}
   # Just to make the timings stabilise accross runs
   # ... probably too much, but who cares
   time {a 1 2} 10000
   time {w a 1 2} 10000
   lappend res proc:[time {a 1 2} 10000]
   lappend res ense:[time {w a 1 2} 10000]
   lappend res [info patchlevel]
   puts [join $res \n]

Building with --disable-shared I get

   sh-3.1# ./tclsh /tmp/test
   proc:2.3583 microseconds per iteration
   ense:3.1632 microseconds per iteration
   8.5a6

and with --disable-shared --enable-threads

   sh-3.1# ./tclsh /tmp/test
   proc:4.1325 microseconds per iteration
   ense:5.8033 microseconds per iteration
   8.5a6
msoferplain2006-10-28 23:21:36
Logged In: YES 
user_id=148712

With ActiveTcl it is even slower (I imagine this is due to
the shared build, as not much optimisation has been done in
proc calls since then):
mig@ice:/home/CVS/tcl_SF_clean/unix$ tclsh /tmp/test
proc:5.4506 microseconds per iteration
ense:7.678 microseconds per iteration
8.5a4

% parray ::activestate::ActiveTcl
::activestate::ActiveTcl(arch)          = linux-ix86
::activestate::ActiveTcl(as,mode)       = normal
::activestate::ActiveTcl(build)         = 261540
::activestate::ActiveTcl(buildtime,fmt) = Sat Apr 15
01:24:58 AM PDT 2006
::activestate::ActiveTcl(buildtime,sec) = 1145089498
::activestate::ActiveTcl(maturity)      = beta-5
::activestate::ActiveTcl(product)       = ActiveTcl
::activestate::ActiveTcl(release)       = 8.5.0.0
msoferplain2006-10-29 00:01:59
Logged In: YES 
user_id=148712

Threaded build using glibc's malloc instead of Tcl's pooled
allocator it is even slower, so the problem is probably not
mainly with the allocator.

mig@ice:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test
proc:4.4455 microseconds per iteration
ense:6.0062 microseconds per iteration
8.5a6
msoferplain2006-10-29 00:08:40
Logged In: YES 
user_id=148712

Disabling the call to TclpCheckStackSpace in TclInterpReady
makes threaded builds quite a bit faster:

mig@ice:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test
proc:3.0335 microseconds per iteration
ense:4.5398 microseconds per iteration
8.5a6
msoferplain2006-10-29 01:33:23
Logged In: YES 
user_id=148712

Hmmm ... my timings are very erratic. Several runs of the
same threaded build, right after each other:

mig@ice:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test
proc:4.48498 microseconds per iteration
ense:6.03318 microseconds per iteration
8.5a6
mig@ice:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test
proc:3.90434 microseconds per iteration
ense:5.86458 microseconds per iteration
8.5a6
mig@ice:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test
proc:4.10458 microseconds per iteration
ense:5.98978 microseconds per iteration
8.5a6
mig@ice:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test
proc:2.1277 microseconds per iteration
ense:2.93122 microseconds per iteration
8.5a6
mig@ice:/home/CVS/tcl_SF_clean/unix$ ./tclsh /tmp/test
proc:4.39368 microseconds per iteration
ense:6.04074 microseconds per iteration
8.5a6
mistachkinplain2006-10-29 09:37:48
Logged In: YES 
user_id=113501


It's probably slower because the previous
TclpCheckStackSpace was a no-op on Unix.
msoferplain2008-01-12 20:13:20
Logged In: YES 
user_id=148712
Originator: YES

Still an issue? If it was due to stack checking it should have been fixed by the new algorithm.
hobbsplain2008-01-14 07:31:12
Logged In: YES 
user_id=72656
Originator: NO

Running the head over tclbench with a threaded and non-threaded build (yes and no below), it is slower (mutexes actually kicking in), but not as serious as the above numbers show.

TCL_INTERP: 1:8.5.1b1 2:8.5.1b1
STARTED 2008-01-13 16:19:59 (runbench.tcl v1.21)
Benchmark 1:8.5.1b1 /home/jeffh/install/linux-ix86/bin/tclsh8.5t-no
abbccdeeeffghkllmmmmnpprrssstuvw 00:02:18 elapsed
131271 milliseconds
Benchmark 2:8.5.1b1 /home/jeffh/install/linux-ix86/bin/tclsh8.5t-yes
abbccdeeeffghkllmmmmnpprrssstuvw 00:02:43 elapsed
157038 milliseconds
msofer Pending ticket [1586292fff]. [History diff]2008-06-28 21:06:03
sf-robotplain2008-07-13 09:20:23
Logged In: YES 
user_id=1312539
Originator: NO

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).
Log in (anonymous is fine) to add a comment.