Page 5 of 5
Re: Love CPU usage
Posted: Sun Nov 01, 2020 3:43 pm
by Felix_Maxwell
On the topic of CPU usage, I wrote a long post wondering about multithreading, then found the wiki page for it here on the site at love.thread.
I am also wondering: what makes pairs() so slow? Is it something to do with C hash tables under the hood?
Re: Love CPU usage
Posted: Sun Nov 01, 2020 7:21 pm
by pgimeno
Felix_Maxwell wrote: ↑Sun Nov 01, 2020 3:43 pm
I am also wondering: what makes pairs() so slow?
It's NYI.
http://wiki.luajit.org/NYI
There's been some effort by a third party to implement next(), but not sure it has been contributed back.
https://blog.cloudflare.com/luajit-hack ... -nyi-list/ . The post also mentions that next() is only part of the story, as LuaJIT is using an optimization that makes interpreted pairs() on par, or even faster, than compiled next(). Regardless, since it breaks traces, the code within a pairs() loop is generally slow, even if the pairs() part of the loop itself may be faster.
(The post gives a lot of insight into LuaJIT's internals, and it's worth a read if you're interested in optimizing your LJ projects)