Skip to content
Tcl Source Code History Of Ticket 3302370
Login

History Of Ticket 3302370

Artifacts Associated With Ticket 3302370

  1. Ticket change [7fc5c43cc5] (rid 97614) by ferrieux on 2011-05-15 10:00:16:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Using [global] instead of [::] in a proc gives a 7x speedup.
      
      % proc f {} {global zzz;for {set i 0} {$i<10000000} {incr i} {incr zzz}}
      % proc g {} {for {set i 0} {$i<10000000} {incr i} {incr ::zzz}}
      % time f
      871320 microseconds per iteration
      % time g
      
      This can be traced to the different bytecode ops used: in the tight loop, the [global] case uses a compiled local (upvarred to the global), while the FQN uses loadScalarStk repeatedly.
      
      I would have assumed that the intrep cacheing of the resolved varname in that literal value "::zzz" would save most of the work, but something else must be increasing the cost...
      6123508 microseconds per iteration
      
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "ferrieux"
    10. subsystem initialized to: "07. Variables"
    11. title initialized to: "Performance gap between [global] and [::]"
    12. type initialized to: "Bug"
  2. Ticket change [a588ab7b5c] (rid 110392) by ferrieux on 2011-05-15 17:05:00:

    1. icomment:
      Hmm, sorry for the bad layout. Copypasta glitch. Summary of timings:
       
       global ->  871320 microseconds
       ::         -> 6123508 microseconds
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  3. Ticket change [8e3dd386f4] (rid 120076) by dkf on 2011-05-25 05:28:58:

    1. icomment:
      I vaguely remember there being a whole bunch of experimentation with variable reference caching in... was it 8.4? I think after 8.4.2 things started to be turned off again because of odd bugs in corner cases, but that's quite a long time ago now so memory might be off.
      
      What follows is "thinking with my mouth open" (except its typed ;-))
      
      It should be possible to cache a Var* in a fully-qualified name, but there's a possibility that it could cause problems with [unset] semantics. Plus the name needs to be interpreter-bound anyway. Ick!
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  4. Ticket change [7fb7eeb30a] (rid 97605) by msofer on 2011-05-25 05:36:27:

    1. icomment:
      This CAN be solved easily enough: when the compiler detects a FQN, it can create a same-named (with qualifiers!) variable in the LVT that is auto-upvared to the global on proc entry. The body then always refers to the one in the LVT.
      
      The same thing could actually be done for [eval] and [uplevel] bodies, even for non qualified names. But in that case it probably requires other changes elsewhere: the whole core assumes that only proc (and lambda, and oo) bodies have an LVT, this assumption could be hidden somewhere unexpected.
      
      Another solution would be to code a fast-path for FQN variables in TEBC, reading the Tcl_Obj intrep. Currently only LVT variables have a fast inlined path, the others call the functions in tclVar.c
      
      
    2. login: "msofer"
    3. mimetype: "text/plain"
    4. username: "msofer"
  5. Ticket change [108c7dd4e1] (rid 94988) by ferrieux on 2011-05-25 14:09:41:

    1. icomment:
      The first solution, even if not generalized to uplevel+eval bodies for now, sounds like an optimum to me... FWIW
      (Wow ! an FQN-named compiled local -- brilliant)
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Ticket change [7acf9738ae] (rid 90401) by ferrieux on 2011-09-24 05:38:49:

    1. icomment:
      Miguel, is this doable ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"