[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] LuaJIT-2.0.0-beta1
- From: David Given <dg@...>
- Date: Sun, 01 Nov 2009 13:38:12 +0000
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Mike Pall wrote:
> It's almost midnight on Halloween here. This is the perfect time
> to release long-awaited, almost mythical open source software ... ;-)
But Christmas isn't for another two months!
> SciMark scores on a 3 GHz Core2 E8400 (single-thread, not vectorized),
> higher numbers are better:
[...]
> LuaJIT 2.0.0-beta1 580.4 | 427.4 1025.0 223.7 303.4 922.5
> LuaJIT 1.1.5 96.7 | 72.0 166.1 37.1 91.8 116.5
> Lua 5.1.4 16.5 | 11.0 27.4 7.6 16.9 19.5
Impressive. However...
I tried the Clue Whetstone benchmark through LuaJIT 2 (which is a
version of the old C Whetstone benchmark 'compiled' into an assortment
of languages). The results are:
Native C 830
C translated to C 530
Java 290
LuaJIT 1 94
LuaJIT 2 36
Lua 13
SpiderMonkey Javascript 9.5
Perl 5 1.7
In fact, I notice that a lot of Clue's tests appear to run slower in
LuaJIT 2 than in LuaJIT 1.
I don't think I'm doing anything particularly stupid --- the docs say I
don't need to do anything particular to turn the JIT on, right? I can
just run a problem with luajit instead of lua and it'll work?
So assuming that I am working LuaJIT correctly there's something about
Clue's output that it's not getting on with. As Clue's Lua output is
mostly dead simple, my initial instinct is to blame the disgusting hack
I'm having to do to emulate gotos:
local state = 0
repeat
while true do
if state == 0 then <code for basic block 0> end
if state == 1 then <code for basic block 0> end
if ...etc.. end
if state == 99 then
<code for basic block 99>
state = 42 break end -- transfer to basic block 42
if ...etc... end
end
end
Could this be upsetting the JIT?
(I have had thoughts about using tail calls to do the transfer of
execution from one basic block to another, but I haven't come up with a
decent way of doing it without doing memory allocations on entry to each
function.)
Here's a complete short function so you can see what it's actually emitting:
_pa = function(fp, stack, H0, H1, H2, H3)
local sp
local H4
local H5
local H6
local H7
local H8
local H9
local H10
local state = 0;
while true do
repeat
if state == 0 then
sp = 0
sp = fp + sp
H4 = 0
state = 1 break end
if state == 1 then
H5 = 6
H6 = H4 < H5 and 1 or 0
if H6 ~= 0 then state = 2 else state = 3 end break end
if state == 2 then
H5 = H1[H0 + 0]
H6 = H1[H0 + 1]
H7 = H5 + H6
H5 = H1[H0 + 2]
H8 = H7 + H5
H7 = H1[H0 + 3]
H9 = H8 - H7
H8 = H9 * H2
H1[H0 + 0] = H8
H9 = H8 + H6
H6 = H9 - H5
H9 = H6 + H7
H6 = H9 * H2
H1[H0 + 1] = H6
H9 = H8 - H6
H10 = H9 + H5
H5 = H10 + H7
H9 = H5 * H2
H1[H0 + 2] = H9
H5 = -H8
H8 = H5 + H6
H5 = H8 + H9
H6 = H5 + H7
H5 = H6 / H3
H1[H0 + 3] = H5
H5 = 1
H6 = H4 + H5
H4 = H6
state = 1 break end
if state == 3 then
do return end
end
until true
end
end
- --
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "There is nothing in the world so dangerous --- and I mean *nothing*
│ --- as a children's story that happens to be true." --- Master Li Kao,
│ _The Bridge of Birds_
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iD8DBQFK7Y9Ef9E0noFvlzgRAr0BAJ9q8ZeRpmAMbHt7xocZO9AzcMo3XgCeII15
9VPvGAXxcDBMO6ehB20mN8c=
=zPLO
-----END PGP SIGNATURE-----