[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua versus Ravi versus Luajit - a simple benchmark
- From: Dibyendu Majumdar <mobile@...>
- Date: Wed, 4 Mar 2015 20:05:30 +0000
On 4 March 2015 at 03:15, KHMan <email@example.com> wrote:
> luajit is doing 3.2 billion iterations a second. Do you have a comparison
> with a straight C sample? That would be informative, indicating the amount
> of overhead we're looking at versus "C compiled with the minimum overhead".
I'd like to say how much I appreciate your document on Lua VM
bytecodes - it has been of great help to me. I will update it for 5.3
when I get some time.
Re C sample - no I haven't done so. I did have a look at the Luajit
dump of machine code - it is really optimized to the bare minimum, so
a C version is unlikely to be much better than that. In any case for
very simple code like this test I suspect a C version when run through
an optimizer would recognize that actually the loop is not necessary
at all - and one could just return the final value! The code only
makes sense in Lua because of the semantics of the loop variable.
I will do comparisons with C when I have more complex examples I can test.
There are obviously a number of optimizations that are possible in
this particular example.
a) Recognizing at compile time that the loop variable is an integer with step 1.
b) Eliminating the "external" variable that is only being read - my
current version updates it at every iteration , which means two
assignments at every iteration (the value and the type) that could be
But I will resist temptation to keep tuning this - and focus on
getting more coverage for now.