Re: lua_yield is painfully slower in LuaJIT 2.0 than Lua 5.1.4

  • From: Coda Highland <chighland@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 8 Oct 2012 20:36:10 -0700

On Mon, Oct 8, 2012 at 7:56 PM, agentzh <agentzh@xxxxxxxxx> wrote:
> Hello!
>
> On Mon, Oct 8, 2012 at 7:42 PM, Coda Highland <chighland@xxxxxxxxx> wrote:
>> A question:
>>
>> How does it add up in terms of real time?
>>
>> It may be that lua_yield is proportionally more expensive in LuaJIT,
>> but I have my doubts that it's ACTUALLY more expensive. Is LuaJIT
>> still capable of doing more in the same amount of real time?
>>
>
> To quote the related paragraph from my last mail to (indirectly)
> answer this question:
>
> "And ab (ApacheBench) also shows that now it is indeed much faster (60k
> q/s) than we were using LuaJIT 2.0 before (50k q/s)."
>
> So that we can see that the standard Lua 5.1.4 interpreter is a lot
> *faster* (17%+ overall) than LuaJIT 2.0 for exactly the same test
> case. This matches the results as shown in the FlameGraphs.
>
> I should add that when I eliminated the lua_yield() call altogether,
> then the same test case can actually achieve 70k q/s using ab with
> LuaJIT 2.0.
>
> Best regards,
> -agentzh
>

Ah, I feel a little foolish that I missed that. It's been a long day.

Another point of note, I'll add, is that while LuaJIT exposes the same
language as Lua, optimum code patterns for the two diverge
substantially. It seems you found that for yourself when you
restructured the code to avoid lua_yield.

Mike will have to weigh in to say whether or not this is a case that
can be improved in LuaJIT or if it's just a pattern to avoid.

/s/ Adam

Other related posts: