lua-users home
lua-l archive

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





How about store the Value and the type separately? And we can optimize
the array with the same type, something like integer arrays.


One downside of using two separate arrays (one for tags and one for values) is decreased memory locality. I did some basic experiments in a simplified setting and what I found was that separate arrays worked OK for sequential access but had worse performance for random access. With random access, most array reads will cause a costly cache miss and if we have two arrays then it is double the cache miss.

We didn't test this in the actual Lua interpreter though, so I can't say for sure if the performance would behave the same as in my simplified test.

> We may also need to change luaH_get* to return the value of TValue instead of `const TValue *`.

It would certainly require changing luaH_get but in addition to that there are also a couple more places with problematic TValue* pointers.

-- Hugo