lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

Sometimes it happens that one spends time attacking the wrong problem
when the real issue is staring at you in the face but you somehow are
blind to it. I had implemented the Lua comparison ops early on - and
it was my plan at the time to specialize these for scenarios where the
type is known. But then I forgot about this. I have been trying out
various ways of improving the JIT code performance for certain
benchmarks but did not get much joy. But while looking at another
unrelated issue was reminded of this pending change.

I have now implemented specialized bytecodes for EQ, LT and LE
operators for situations where the operands are known to be number or
integer types - this allows me to inline the JIT code for these. I am
happy to report that this has helped improve performance.

The updated benchmarks are reproduced below.

+---------------+---------+------------+------------+
| Program       | Lua5.3  | Ravi(LLVM) | Luajit 2.1 |
+===============+=========+============+============+
|fornum_test1   | 9.187   | 0.31       | 0.309      |
+---------------+---------+------------+------------+
|fornum_test2   | 9.57    | 0.917      | 0.906      |
+---------------+---------+------------+------------+
|fornum_test3   | 53.932  | 4.598      | 7.778      |
+---------------+---------+------------+------------+
|mandel(4000)   | 21.247  | 1.582      | 1.633      |
+---------------+---------+------------+------------+
|fannkuchen(11) | 63.446  | 4.55       | 4.751      |
+---------------+---------+------------+------------+
|matmul(1000)   | 34.604  | 2.942      | 0.968      |
+---------------+---------+------------+------------+

Following points are worth bearing in mind when looking at above benchmarks.

1. For Ravi the timings above do not include the LLVM compilation time.
   But LuaJIT timings include the JIT compilation times, so they show
   incredible performance.

2. The Ravi benchmarks are based on code that uses optional static types.