Closed An0nyMooUS closed 2 years ago
hi, I am curious what you see with this:
local function x()
local j: number=0.0
for i=1,1000000000 do
j = j+1.0
end
return j
end
hi, I am curious what you see with this:
local function x() local j: number=0.0 for i=1,1000000000 do j = j+1.0 end return j end
Same time. (~2.5s)
hmm. It was half the time in my test, but I didn't check LuaJIT. The current version of Ravi uses MIR JIT - that don't optimize as well as LLVM. With LLVM this test would be 0 secs as it gets rid of the loop.
hmm. It was half the time in my test, but I didn't check LuaJIT. The current version of Ravi uses MIR JIT - that don't optimize as well as LLVM. With LLVM this test would be 0 secs as it gets rid of the loop.
why LLVM backend is removed? LLVM is better than MIR jit. i thnk 🤔
Its too big - 20 x bigger than Ravi in binary size. Doesn't make sense
Its too big - 20 x bigger than Ravi in binary size. Doesn't make sense
yep. i thnk so. but for performance is good.
i tryed AOT compile, same time. (~2s) (MSVC 2022 - flags: /Ox /Oi)
But you can try a different option
local x = compiler.load([[
local j:number =0.0
for i=1,1000000000 do
j = j+1.0
end
return j
]]
)
local t1 = os.clock()
local y = x();
local t2 = os.clock()
-- print(y)
--
assert(y == 1000000000.0)
print("time taken ", t2-t1);
Its too big - 20 x bigger than Ravi in binary size. Doesn't make sense
yep. i thnk so. but for performance is good.
i tryed AOT compile, same time. (~2s) (MSVC 2022 - flags: /Ox /Oi)
Try will clang or gcc. Also use the version I suggested
But you can try a different option
local x = compiler.load([[ local j:number =0.0 for i=1,1000000000 do j = j+1.0 end return j ]] ) local t1 = os.clock() local y = x(); local t2 = os.clock() -- print(y) -- assert(y == 1000000000.0) print("time taken ", t2-t1);
Oh! Nice! (0.777s)
Why is this not standard? For every lua file, i need compiler.load (string...)
?
Hm....
JIT compiles a chunk of code and returns a closure on the stack representing the compiled output.
this should be standard 🤔 do not you think?
Hm... compiler.load
not works for all files.
https://raw.githubusercontent.com/MaHuJa/CC-scripts/master/sha256.lua (Var args not supported)
static lua_State* state = nullptr;
if (!state)
{
state = luaL_newstate();
luaL_openlibs(state);
raviV_setjitenabled(state, true);
raviV_setminexeccount(state, 0); // Force compile MIR JIT
raviV_setoptlevel(state, 3);
}
if ((luaL_loadfile(state, filePath.c_str()) != LUA_OK))
{
printf("[Uncompressed Buffer Fail] %s\n", lua_tostring(state, -1));
return false;
}
else
lua_pcall(state, 0, 0, 0); // Same time. (2.5s)
...........
Hm...
compiler.load
not works for all files.https://raw.githubusercontent.com/MaHuJa/CC-scripts/master/sha256.lua (Var args not supported)
Yeah, this is work in progress new compiler. It doesn't support some features.
But, note that for general case, LuaJIT is a better solution; Ravi can do well if you your code is heavy in numerics and you are willing to annotate with types.
LuaJIT:
Ravi:
Why Ravi is slow? Its correct? I think JIT is not enabled 🤔 (my frist time using this)