Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 3db3ba7fc91c1d2715f7fb871ea25eb93f0aded87686429462ae3a9a9f4bb1e5
Ticket: 4731d31eff3e2245b2300462b9185ab1b2645810
iTcl and Tcl 8.6 performance with Tcl_Preserve
User & Date: sebres on 2019-02-07 22:40:59
Changes

  1. icomment:
    So as assumed it looks like Itcl regression, and I am mostly ready with a first shot, illustrating this behavior in Itcl.
    
    Here you will find my the new branch with rewritten several memory facilities (preservation resp. release of classes and objects/variables) in Itcl.
    
      [https://core.tcl.tk/itcl/timeline?r=sebres-memopt-perf-branch|itcl/sebres-memopt-perf-branch]
    
    This huge performance regression was initially introduced in [https://core.tcl.tk/itcl/info/c7e729d15408ed4e|[c7e729d15408ed4e]] which was from begin basically inappropriate for this purposes.<br/>
    I think the intention was to find and provide instrumentation to do (auto)-free via freeProc of the released Itcl-primitives (like Tcl_EventuallyFree does it in Tcl), just used for this purposes totally unsuitable function-set (Tcl_Preserve/Tcl_Release) which is basically used in Tcl to protect large blocks resp. for managing storage. For other things even if it is anyway not allowed across threads (like this Itcl basic facilities are), Tcl uses simple ref-counting models.
    
    Just, because several routines (like Itcl_PreserveData/Itcl_ReleaseData) are public interface now, I was forced to rewrite internals only without great impact of the public API (I'm pretty sure I gets anyway several objections from TCT about).
    
    The first results are:
    
    <code><pre style="padding-left:10pt">
      1) Rate of Itcl-classes only - 83.5470 µs/# 11963 # 11969.3 #/sec 999.473 nett-ms
      1) Rate of Itcl-vars only    - 2.747414 µs/# 357526 # 363978 #/sec 982.272 nett-ms
      2) Rate of Itcl-classes only - 78.6557 µs/# 12707 # 12713.6 #/sec 999.478 nett-ms
      2) Rate of Itcl-vars only    - 2.712135 µs/# 362093 # 368713 #/sec 982.045 nett-ms
      3) Rate of Itcl-classes only - 78.0048 µs/# 12812 # 12819.7 #/sec 999.398 nett-ms
      3) Rate of Itcl-vars only    - 2.602542 µs/# 377227 # 384239 #/sec 981.749 nett-ms
    </pre></code>
    
    Further good news is the growth of time is stopped by growth of the variable number (due to list/hash-less implementation). So it was able to create 40K classes as well as over a 1M variables.
    
    As well as by your initial test code from here (as diff for before/after on my machine) it looks now:
    
    <code><pre style="padding-left:10pt">
    <span style="color: #ff0000">- Initial 10 classes - 78647 microseconds per iteration</span>
    <span style="color: #009800">+ Initial 10 classes -  4729 microseconds per iteration</span>
    <span style="color: #ff0000">-   Final 10 classes - 75752 microseconds per iteration</span>
    <span style="color: #009800">+   Final 10 classes -  5037 microseconds per iteration</span>
    </pre></code>
    
    Although I'm not completely ready here (still some little checks, find and fixes of other parallel regressions, review, documentation, convince of TCT etc), but you can check/try this if you want.
    
    Anyway I let this ticket open, because I've another performance-related branch where the Tcl_Preserve/Tcl_Release facilities are rewritten from me and don't have the regression (you observed) by growth of blocks number.<br/>
    Just as already said this mechanism is totally inappropriate for Itcl primitives as it was used.
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"