lua-users home
lua-l archive

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

Florian Weimer wrote:
> It seems that if you use non-constant keys chosen from a small set,
> the performance hit from using tables is much smaller.  Isn't that the
> more relevant case?

Only the access pattern for the keys which are _not_ in the proxy
table matters. And only whether the last such key is different
from the next one. If the branch predictor can't predict this
pattern, then you get the performance hit.

So 'a a a a' is fine, and 'a b a b' is fine, too. But 'a a b' or
'a a b b' or variations thereof are bad (depending on how smart
your CPU's branch predictor is). That's why simplistic tests don't
catch this problem.