[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Could metatables easily be faster?
- From: Hugo Musso Gualandi <hgualandi@...>
- Date: Wed, 18 May 2022 20:49:05 +0200
Such a benchmark would require a substantial time investment, while
someone familiar with Lua's implementation may highlight a problem
which is not performance-dependent.
You might not realize it, but you already are more familiar with the
implementation than you think ;) One nice thing about Lua having a
small implementation is that it is not that difficult to wrap your head
around the internals workings of the interpreter.
I encourage you to experiment what happens if you change metatables to
use integer indices. For the purposes of the experiment, it doesn't
have to be a well rounded patch. You can make something super hacky.
The main question I have is whether we would get a performance boost
for the integer keys, vs hashing an interned short string. When we use
a short string as a key, we don't need to recompute the hash every time
because the hash is already pre-computed and stored inside the string
object. The only part that is different is the logic for getting the
value from the hash part vs from the array part.
-- Hugo