[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Benchmarking a custom _while loop in Lua vs. LuaJIT (and question about tail calls)
- From: Mike Pall <mikelu-1002@...>
- Date: Thu, 18 Feb 2010 15:00:00 +0100
Pierre-Yves Gérardy wrote:
> * _while() is almost as fast as a vanilla while loop in LuaJIT
No, both generate the same code and are the same speed. Your
measurements are too short and your system does not provide enough
timing accuracy (desktop Linux nowadays uses 250Hz => 4ms).
> * the overhead of a tail call relative to a while loop (test 3 and 2
> respectively) is only halved in LuaJIT, which is far from the gains it
> provides usually.
> The first two points are just amazing, but the third one is
> puzzling... Is there somthing inherently slow in the elimination of
> tail calls? Or hasn't it been optimized [ yet | on purpose ]?
Sure, it does tail call elimination. But that's an entirely
different matter than compiling tail-recursion. It's running in
the interpreter right now (still 6x faster than Lua).
"Recursion is not traced yet."
That said, I'm working on it right now. All loops run the same
speed in my work branch (not pushed yet):
$ time luajit while.lua
$ time luajit _while.lua
$ time luajit _while_recursive.lua