Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 7fc5c43cc5fe6b6304b9e7bdf88dbd3703966891
Ticket: 3302370fffffffffffffffffffffffffffffffff
Performance gap between [global] and [::]
User & Date: ferrieux on 2011-05-15 10:00:16
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed 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 changed to: "None"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "ferrieux"
  10. subsystem changed to: "07. Variables"
  11. title changed to: "Performance gap between [global] and [::]"
  12. type changed to: "Bug"