Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-04-05
23:19 • Closed ticket [1174551fff]: TclDecrRefCount performance plus 3 other changes artifact: bf76540515 user: msofer
21:30 • Ticket [1174551fff]: 4 changes artifact: 7c9861e9dc user: dkf
2005-04-04
06:35 • Ticket [1174551fff]: 4 changes artifact: d3be3a7b0d user: msofer
06:35 • Add attachment TDRCpatch2 to ticket [1174551fff] artifact: bb4a817252 user: msofer
2005-04-03
04:48 • Ticket [1174551fff] TclDecrRefCount performance status still Open with 4 oth... artifact: 9b0b42187e user: msofer
03:05 • Ticket [1174551fff]: 4 changes artifact: daa932caa1 user: msofer
2005-04-02
04:02 • Ticket [1174551fff]: 4 changes artifact: c71575130d user: msofer
2005-04-01
16:12 • Ticket [1174551fff]: 4 changes artifact: 4dc5768a8e user: dkf
08:27 • Ticket [1174551fff]: 4 changes artifact: 98b7cbb2dc user: msofer
01:27 • New ticket [1174551fff]. artifact: 11931fb638 user: msofer

TclDecrRefCount performance

Closed / Accepted1174551fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2005-04-01 01:27:07
Ever since the fix of [Bug ???] the macro
TclDecrRefCount became rather heavy - in both space and
runtime. This patch reduces a lot of weight in the
macro for the most frequent use cases - when 
   objPtr->typePtr->freeIntRepProc == NULL

Note that these are mostly the objects that the core
allocs and frees repeatedly - ints, wides, doubles,
empties, type NULLs, ... 

Please review: IIUC, this does not interfere with the
safety mechanism implemented in the bugfix.
msoferplain2005-04-01 08:27:07
File Added - 128031: TDRCpatch
dkfplain2005-04-01 16:12:19
Logged In: YES 
user_id=79902

Would work, but I do not (yet) approve of the patch. There
ought to be a way to arrange for heavy users of TDRC (i.e.
TEBC) to avoid frequent calls to TclObjInitDeletionContext()
instead of recomputing it every time through, since this
will hit threaded code disproportionately hard.

Also, if the patch is applied, most of the deletion context
machinery ought to be moved to tclObj.c anyway.
msoferplain2005-04-02 04:02:11
File Added - 128130: TDRCpatch

Logged In: YES 
user_id=148712

New patch - moving the deletion context machinery to tclObj.c

The really heavy users of TDRC (TEBC) most frequently free
objects with freeIntRepProc==NULL: either freshly created by
string concatenation, or a numerical result of a
computation. The macro is as fast and small as possible for
that case. The other cases pay the penalty of a function
call to TclFreeObj.

An alternative approach is keeping TDRC unchanged, but
making the deletion context cheaper to access repeatedly
(either by caching it at TEBC entry, or in a slot in the
interp structure). Even then, the overhead is
non-negligible, especially for objs without a string rep -
as can be measured in an unthreaded build.

As discussed in the chat, we can later factor the context
lookup out of TclFreeObj, and have a version that takes
interp as argument to allow for faster access. This version
can then be used for TDRC, while leaving T_DRC unchanged.
msoferplain2005-04-03 03:05:21
File Deleted - 128130: 



File Added - 128229: TDRCpatch2

Logged In: YES 
user_id=148712

Small change to the patch - extending the speed gains to
Tcl_DecrRefCount.
msoferplain2005-04-03 04:48:27
Logged In: YES 
user_id=148712

Patch committed to msofer-wcodes-branch, where the speedup
is remarkable. In HEAD most benchmarks seem to become
slightly faster, some (LOOP for, iterate string) get a 15%
boost.
msoferplain2005-04-04 06:35:26
File Deleted - 128229: 



File Added - 128358: TDRCpatch2
dkfplain2005-04-05 21:30:04
Logged In: YES 
user_id=79902

If it speeds things up and works, let's go with that. :^)
msofer Closed ticket [1174551fff]. [History diff]2005-04-05 23:19:04
Log in (anonymous is fine) to add a comment.

Attachments: