17 comments

[ 2.8 ms ] story [ 51.1 ms ] thread
Does anyone know of a good "compile to js" lua implementation ?
Thats actually difficult, eg Lua has coroutines, a function can be a hash table key and other incompatibilities. There are some but they are fairly limited by this. This is the main implementation https://github.com/mherkender/lua.js
Would be interesting to compare performance to the other ways of getting Lua to run in the browser, which include writing a Lua bytecode interpreter in JS, converting Lua to JS, and code generation from bytecode.

https://github.com/creationix/brozula https://github.com/mherkender/lua.js (and others, I had a list somewhere)

Quite a few companies are using Lua->JS as a way of doing write once run cross platform games eg we had this talk at London Lua http://www.londonlua.org/luajavascript/index.html

Is there an asm.js port of Lua?
Why would you need an asm.js port of lua? Just use LuaJIT it's already faster then asm.js. And Lua itself is already faster then Javascript.
>Score: 130

>binarytrees 46.051 seconds

Without any frame of reference, those values are meaningless.

However there is one I can evaluate:

>1.58 MFLOPS

Given I have an i7-2600 and its flops on benchmarks[1] (FPU Flops score: 8500.09 MFlops), that tells me something I could have guessed: performance is 3 orders of magnitude worse than native high performing code.

Still, in order for this comparison to be complete, I'll have to

- try this benchmark in Firefox with OdinMonkey, the new and very promising JS engine[2]

- run a similar benchmark with "native" LUA

edit: results obtained on W7 SP1 with 16GO RAM and Chrome 27.

1: http://www.maxxpi.net/results/show.php?ID=c3x2c5w6d7b7

2: did you know the logo was awesome? https://wiki.mozilla.org/File:Odinmonkey800.jpg

>Without any frame of reference, those values are meaningless.

How about we compile some results right here?

Below is what I get on an AMD Phenom II X4 965 PC with 8 GB RAM running Linux Mint 13 Maya, kernel version 3.2.0-48-generic x86_64.

— Lua.vm.js in Firefox 21.0

    Score:      115
    binarytrees 56.978 seconds
    scimark     1.79   MFLOPS
    startup     0.431  seconds
— Native Lua 5.2.2

    ~> lua scimark.lua
    FFT        14.65  [1024]
    SOR        30.41  [100]
    MC          9.32  
    SPARSE     19.32  [1000, 5000]
    LU         23.70  [100]

    SciMark    19.48  [small problem sizes]

    ~> time lua binarytrees.lua 14.72
    stretch tree of depth 15     check: -1
    53974    trees of depth 4    check: -53974
    13493    trees of depth 6    check: -13492
    3373     trees of depth 8    check: -3372
    843      trees of depth 10   check: -842
    210      trees of depth 12   check: -210
    52       trees of depth 14   check: -52
    long lived tree of depth 14  check: -1
    lua binarytrees.lua 14.72  5,99s user 0,01s system 99% cpu 6,001 total
— Geekbench-2.4.3-Linux on the same computer

http://browser.primatelabs.com/geekbench2/2076712 (the page includes detailed PC specifications)

Edit: redid the native benchmarks with Lua 5.2.2.

-----

Edit 2: The same set of benchmarks gives the following results on a ThinkPad X61s laptop with a Core 2 Duo L7500 CPU and 4 GB RAM running Linux Mint 13 Maya, kernel version 3.5.0-32-generic x86_64:

— Lua.vm.js in Firefox 21.0

    Score:      59
    binarytrees 117.675 seconds
    scimark     0.95    MFLOPS
    startup     0.822   seconds
— Native Lua 5.2.2

    ~> lua scimark.lua
    FFT         6.55  [1024]
    SOR        15.36  [100]
    MC          4.11  
    SPARSE     10.24  [1000, 5000]
    LU         12.40  [100]

    SciMark     8.73  [small problem sizes]

    ~> time lua binarytrees.lua 14.72
    stretch tree of depth 15     check: -1
    53974    trees of depth 4    check: -53974
    13493    trees of depth 6    check: -13492
    3373     trees of depth 8    check: -3372
    843      trees of depth 10   check: -842
    210      trees of depth 12   check: -210
    52       trees of depth 14   check: -52
    long lived tree of depth 14  check: -1
    lua binarytrees.lua 14.72  9,63s user 0,04s system 99% cpu 9,713 total
— Geekbench-2.4.3-Linux

http://browser.primatelabs.com/geekbench2/2077111

> Without any frame of reference, those values are meaningless.

The page explains how to run them natively as well.

> performance is 3 orders of magnitude worse than native high performing code.

Performance depends on the browser, which did you test on (there are some notes about that on the page)? Also, you can't just compare FLOPS in one test to a theoretical maximal FLOPS on your CPU (or another test), since it depends on the code being run.

This is going to be tracked in realtime here, including a comparison to native,

http://arewefastyet.com/#machine=11&view=breakdown&suite=asm...

(but so far it hasn't shown results for that test yet, just an empty slot, hopefully later today though).

For the sake of sharing my results using my low end laptop:

  Score:        34
  binarytrees   206.886 seconds
  scimark       0.49    MFLOPS
  startup       1.19    seconds
Using AMD E450, linux x64, Firefox 21.

And as you say without other results at the page to compare I'm not sure how bad or good this is.

When people blog about don't use default bootstrap template, I often take it with a grain of salt. Now i'm absolutely positive.
what?
Did you mean use the default bootstrap? I'm confused what you meant.
(comment deleted)