Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: bdf087eaa5f22f2cfeedc7681221baf9de571123
Ticket: 1750051fffffffffffffffffffffffffffffffff
The Big Var Reform of 2007
User & Date: msofer on 2007-07-08 22:00:45
Changes

  1. assignee changed to: "msofer"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    The Big Var Reform of 2007 (partial implementation)
    _________________
    Present Situation
    
    Up to 8.5a6 a variable requires (all numbers on 32 bit platforms, assuming use of the threaded allocator ''zippy''):
    
    * Compiled local variables
      - 32 bytes on the Tcl stack
    
    * Hashtable variables (namespace vars, array elements, runtime defined locals): 
      - 32 bytes for the Var struct: zippy allocates 64 bytes
      - Tcl_HashEntry 
        . varnames of up to 7 chars: 20/24 bytes, zippy allocates 32 bytes
        . varnames of up to 79 chars: zippy allocates 64 bytes
    
    Most variable accesses read first the flags (field #8), then the value (field #1).
    __________
    This patch
    
    * Compiled local variables
      - 8 bytes on the Tcl stack; this has also an impact on proc initialisation and cache friendliness of local variable access (2 words/var instead of 8) 
    
    * Hashtable variables (namespace vars, array elements, runtime defined locals): single alloc for Var (12 bytes) and Tcl_HashEntry (20+ bytes)
      - 64 bytes allocated by zippy for varnames of up to 119 chars
    
    Most variable accesses read first the flags (field #1), then the value (field #2).
    
    The patch passes the testsuite, valgrind soon.
    ___________
    Forthcoming
    
    By moving to Tcl_Obj keys we can reduce the hashTable variables to 24 bytes independent of name length (zippy -> 32), plus a possibly shared Tcl_Obj storing the name. If it is stored in the literal table we can also
    insure faster key comparison, also in many "fail" cases. A further advantage is that no string is copied on variable creation.
    _________________________________________
    Impact on extensions that include tclInt.h 
    
    Extensions that allocate or access Var structs directly may lose binary compatibility. It should be relatively simple to restore source compatibility. Special attention should be paid if they allocate or init
    variable tables, as these are *not* plain string-keyed Tcl anymore.
    
    Extensions that alloc or access CallFrame or ByteCode structs may lose binary compat, as the structs are grown by one field that must be initialised to NULL.
    
    Extensions that alloc or access Interp structs may lose binary compat, as the structs are grown by one field that must be initialised properly.
    
    
  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: "msofer"
  10. subsystem changed to: "07. Variables"
  11. title changed to: "The Big Var Reform of 2007"
  12. type changed to: "Patch"