lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> How much data is there really in a Node? [...] That's a wasting of
> 40-45% of the space.
> [...]
> Has this arisen as an issue in practice or am I just seeing a theoretical
> potential issue?
> [...]
> For example, a Node could be represented as:
> [...]

For very small (record) tables, there are other "heavy" overheads
involved (malloc overhead and the Table structure), so that optimization
would not make a big improvement. Arrays (tables indexed by integers)
do not use Node (in Lua 5.0). So, that change would mostly improve
middle-size records.


> TObject: 16 bytes. A type value followed by a double which because of 8
> byte alignment forces the effective size up to 16 bytes.

Linux/gcc aligns doubles in 4 (not 8). In Visual C you can set the
alignment to 4 too. Last time I tried it, it had no noticeable impact
on Lua's performance. With this alignment, the waste is 0 (if you
assume that the structure Node needs padding for its own allignment).


> Is this worth playing with?

The gain is not that big, but maybe the changes are not that big either.

-- Roberto