Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl_ExprObj: avoid Tcl_GetStringFromObj

Closed1522510fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-07-14 12:04:44
This patch avoids an call to Tcl_GetStringFromObj on 
byte-compiled expressions in Tcl_ExprObj (common 
path). It's speed up (slightly) the recursive 
benchmark from the "Computer Language Shootout". Not 
much, but the patch is very simple.
fridolinplain2006-07-14 19:04:44
File Added - 184921: avoid-getstringfromobj.diff
dgpplain2006-07-17 21:25:54
Logged In: YES 
user_id=80530


what version of Tcl sources is
the patch for?

The patch appears to be all about
replacing one form of special-case
optimization with some other form
of special-case optimization.
I don't know that that makes much
sense without some benchmarking
data guiding the way.

The old optimizations might
well be relics and better
removed, but some measurements
ought to tell us that.  Got any?

That said, Tcl_GetStringFromObj()
on a Tcl_Obj that already has
a string rep (which an expression
should) ought to be really cheap,
so I'd expect the patch to make
little difference.  What's the
data say?
fridolinplain2006-07-27 14:43:28
Logged In: YES 
user_id=13583

Sorry, the patch was done against tcl8.5a4.

Vefore submitting I made some test with the attached 
program, which does mostly expr-calculations. It is taken 
from the  "Computer Language Shootout".
fridolinplain2006-07-27 14:43:29
File Added - 186413: recursive.tcl
fridolinplain2006-07-27 14:56:32
Logged In: YES 
user_id=13583

The data are not very impressive.
 
Done under linux: with the patch:

clsh recursive.tcl 3  24,82s user 0,07s system 96% cpu 
25,661 total
tclsh recursive.tcl 3  24,30s user 0,03s system 97% cpu 
24,968 total
tclsh recursive.tcl 3  24,58s user 0,02s system 93% cpu 
26,280 total
tclsh recursive.tcl 3  24,61s user 0,04s system 93% cpu 
26,256 total

without the patch:
tclsh recursive.tcl 3  25,17s user 0,03s system 93% cpu 
27,031 total
tclsh recursive.tcl 3  25,10s user 0,07s system 92% cpu 
27,254 total
tclsh recursive.tcl 3  24,80s user 0,08s system 97% cpu 
25,541 total
tclsh recursive.tcl 3  24,78s user 0,05s system 96% cpu 
25,644 total

I'll upload a slightly simpler patch. There just a block is 
moved.
fridolinplain2006-07-27 14:56:53
File Added - 186414: tclExecute.c.diff

Logged In: YES 
user_id=13583

The data are not very impressive.
 
Done under linux: with the patch:

clsh recursive.tcl 3  24,82s user 0,07s system 96% cpu 
25,661 total
tclsh recursive.tcl 3  24,30s user 0,03s system 97% cpu 
24,968 total
tclsh recursive.tcl 3  24,58s user 0,02s system 93% cpu 
26,280 total
tclsh recursive.tcl 3  24,61s user 0,04s system 93% cpu 
26,256 total

without the patch:
tclsh recursive.tcl 3  25,17s user 0,03s system 93% cpu 
27,031 total
tclsh recursive.tcl 3  25,10s user 0,07s system 92% cpu 
27,254 total
tclsh recursive.tcl 3  24,80s user 0,08s system 97% cpu 
25,541 total
tclsh recursive.tcl 3  24,78s user 0,05s system 96% cpu 
25,644 total

I'll upload a slightly simpler patch. There just a block is 
moved.
msofer Pending ticket [1522510fff]. [History diff]2006-09-30 00:28:01
sf-robotplain2006-10-14 09:20:07
Logged In: YES 
user_id=1312539

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.

Attachments: