lua-users home
lua-l archive

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


Hi, list!

I've got an impression that LJ2 b2 does not optimize functions with varargs.

I should have digged more before asking, sorry if this came up before.

Anyway.

I'm running this silly benchmark: http://github.com/agladysh/luamarca/blob/master/bench/arguments.lua

luajit2
-------------------------------------------------------------------
                name |     rel | abs s / iter = us (1e-6 s) / iter
-------------------------------------------------------------------
     assert_is_alloc |     nan |   0.00 /   10000000 = 0.000000 us
        plain_assert |     nan |   0.00 /   10000000 = 0.000000 us
           assert_is |     inf |   0.01 /   10000000 = 0.001000 us
  args_select_simple |     inf |   3.23 /   10000000 = 0.323000 us
 args_recursive_simp |     inf |   3.26 /   10000000 = 0.326000 us
   args_recursive_ln |     inf |   3.63 /   10000000 = 0.363000 us

luajit -O
-------------------------------------------------------------------
                name |     rel | abs s / iter = us (1e-6 s) / iter
-------------------------------------------------------------------
           assert_is |  1.0000 |   4.13 /   10000000 = 0.413000 us
        plain_assert |  1.0847 |   4.48 /   10000000 = 0.448000 us
 args_recursive_simp |  1.4189 |   5.86 /   10000000 = 0.586000 us
   args_recursive_ln |  1.4383 |   5.94 /   10000000 = 0.594000 us
  args_select_simple |  1.7724 |   7.32 /   10000000 = 0.732000 us
     assert_is_alloc |  3.0993 |  12.80 /   10000000 = 1.280000 us

lua
-------------------------------------------------------------------
                name |     rel | abs s / iter = us (1e-6 s) / iter
-------------------------------------------------------------------
        plain_assert |  1.0000 |  11.86 /   10000000 = 1.186000 us
           assert_is |  1.0793 |  12.80 /   10000000 = 1.280000 us
  args_select_simple |  1.5776 |  18.71 /   10000000 = 1.871000 us
 args_recursive_simp |  1.7083 |  20.26 /   10000000 = 2.026000 us
   args_recursive_ln |  1.7749 |  21.05 /   10000000 = 2.105000 us
     assert_is_alloc |  2.0135 |  23.88 /   10000000 = 2.388000 us

It seems that in LT 1 recursion is the fastest way to walk through varargs. In LJ2 it is the slowest way. Would it always be like this or is it just some beta version artifact?

I want to write fastest possible arguments() function for LJ2.

I remember that LJ2 does not do full-blown optimization yet, so, most likely, it is too early to say anything yet. I'm fine with waiting for the definite answer.

But, perhaps, something is known at this point. I use vararg a lot when I write generic code, so I want, from the beginning, to write it in the way LJ2 would like it.

Alexander.

P.S. To reproduce, clone http://github.com/agladysh/luamarca (or download GitHub snapshot) and run

$ ./run_benchmark.sh bench/arguments.lua 1e7

You should have luajit2 somewhere in path.