Ticket UUID: | 1174551 | |||
Title: | TclDecrRefCount performance | |||
Type: | Patch | Version: | None | |
Submitter: | msofer | Created on: | 2005-04-01 01:27:07 | |
Subsystem: | 10. Objects | Assigned To: | dkf | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2005-04-05 23:19:04 | |
Resolution: | Accepted | Closed By: | msofer | |
Closed on: | 2005-04-05 16:19:04 | |||
Description: |
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. | |||
User Comments: |
dkf added on 2005-04-05 21:30:04:
Logged In: YES user_id=79902 If it speeds things up and works, let's go with that. :^) msofer added on 2005-04-04 06:35:26: File Deleted - 128229: File Added - 128358: TDRCpatch2 msofer added on 2005-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. msofer added on 2005-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. msofer added on 2005-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. dkf added on 2005-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. msofer added on 2005-04-01 08:27:07: File Added - 128031: TDRCpatch |
Attachments:
- TDRCpatch2 [download] added by msofer on 2005-04-04 06:35:26. [details]