The great (internal) Var reform of 2007

Miguel Sofer

The Var struct used as internal representation for Tcl's variables currently contains six pointers and 2 integers, or 32 bytes on a 32-bit platform. For variables in hashtables, be they namespace variables or array elements, it we also maintain a hash entry structure consuming a further minimum of 24 bytes, but typically 28. These requirements reflect a growth history of the structure, and are far from optimal. We will explain the requirements that have to be satisfied, how they gave rise to this structure, and a way to thin them down considerably [1]: compiled variables are reduced to 8 bytes (75% reduction), hashtable variables to a grand total of 24 bytes (60% reduction). Further performance advantages of the new implementation will also be described.