Love CPU usage

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
Felix_Maxwell
Prole
Posts: 24
Joined: Wed Dec 04, 2019 3:15 pm

Re: Love CPU usage

Post 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?
User avatar
pgimeno
Party member
Posts: 3674
Joined: Sun Oct 18, 2015 2:58 pm

Re: Love CPU usage

Post 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)
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests