Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tcl Performance hotspot in TclCallVarTraces() (while migrating from 8.4 to 8.6)

76 views
Skip to first unread message

Trey Jackson

unread,
Sep 19, 2018, 1:00:35 PM9/19/18
to
All,

In my profiling of performance tests that run slowly in Tcl 8.6, I've found that TclCallVarTraces() is taking between 3% and 15% of total runtime for these tests.

Specifically, the runtime is in Tcl_Preserve()/Tcl_Release() of the two different pointers: Interp* and VarTrace*.

The truncated call stack for the hotspot is:

libtcl8.6.so ! Tcl_Preserve - tclPreserve.c
libtcl8.6.so ! TclCallVarTraces + 0x96 - tclTrace.c:2617
libtcl8.6.so ! TclPtrGetVarIdx + 0xb1 - tclVar.c:1410
libtcl8.6.so ! TEBCresume + 0xfcd - tclExecute.c:3324
libtcl8.6.so ! TclNRRunCallbacks + 0x46 - tclBasic.c:4435

Note: the calls to TclNRRunCallbacks begin to differ, most from Itcl, some from Tk, etc., but the above is the most common portion of the stack (with the line number in tclTrace.c changing, depending on whether the hotspot was for Interp* or VarTrace*)

My thought is to add reference counts to each of those structs and do the appropriate counting/freeing. This worked great in Itcl (see the commit: https://core.tcl.tk/itcl/info/7388d76981118df3), and the same functional change worked just as well in an internal project here.

Questions:

1) Are there reasons that those particular structs shouldn't change? (akin to Tcl_Obj not changing until Tip 445 is complete)

2) If I were to make the change, what's the process for me submitting those changes? Do I just submit a patch (set of diffs), do I commit on a Fossil branch? Or, do I just request this kind of change and hope for the goodwill of the community?



thanks,

TJ


ps. Context: My other recent performance issue was reported here: https://groups.google.com/forum/#!topic/comp.lang.tcl/Qd0Q11CxjgQ

pps. The Itcl performance issue (fixed already, yay!) was in the comments here: https://sourceforge.net/p/incrtcl/bugs/271/

Trey Jackson

unread,
Oct 9, 2018, 2:25:34 PM10/9/18
to
On Wednesday, September 19, 2018 at 10:00:35 AM UTC-7, Trey Jackson wrote:
> All,
>
> In my profiling of performance tests that run slowly in Tcl 8.6, I've found that TclCallVarTraces() is taking between 3% and 15% of total runtime for these tests.
>
> Specifically, the runtime is in Tcl_Preserve()/Tcl_Release() of the two different pointers: Interp* and VarTrace*.
>
[snip]
> My thought is to add reference counts to each of those structs and do the appropriate counting/freeing. This worked great in Itcl (see the commit: https://core.tcl.tk/itcl/info/7388d76981118df3), and the same functional change worked just as well in an internal project here.
>
> Questions:
>
> 1) Are there reasons that those particular structs shouldn't change? (akin to Tcl_Obj not changing until Tip 445 is complete)

Any response to whether or not Interp or VarTrace structures can be updated?

It doesn't appear they are exposed to the public (like Tcl_Obj is)...
0 new messages