Artifacts Associated With Ticket 3302370fffffffff
Ticket change [7fc5c43cc5] (rid 97614) by ferrieux on 2011-05-15 10:00:16:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- 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 - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "ferrieux"
- subsystem initialized to: "07. Variables"
- title initialized to: "Performance gap between [global] and [::]"
- type initialized to: "Bug"
Ticket change [a588ab7b5c] (rid 110392) by ferrieux on 2011-05-15 17:05:00:
- icomment:
Hmm, sorry for the bad layout. Copypasta glitch. Summary of timings: global -> 871320 microseconds :: -> 6123508 microseconds
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [8e3dd386f4] (rid 120076) by dkf on 2011-05-25 05:28:58:
- 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!
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [7fb7eeb30a] (rid 97605) by msofer on 2011-05-25 05:36:27:
- 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
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [108c7dd4e1] (rid 94988) by ferrieux on 2011-05-25 14:09:41:
- 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)
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [7acf9738ae] (rid 90401) by ferrieux on 2011-09-24 05:38:49:
- icomment:
Miguel, is this doable ?
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment: