Hello list,
I was porting my Fractal viewer from Flash/AS3 to Killa (my language based in Lua 5.2) when I noticed a very noticeable slow down in the Love counterpart.
I was incredulous at first and translated the code to Lua to check if it was some problem with Killa but it was the same. I went to test with LuaJIT, it took half of the time but still double than flash to redraw the fractal. I know that the Flash player optimizes the virtual machine code using JIT but I was under the impression that Lua was faster. I'm using Love 0.8 with canvas, I heard they are slow but I was expecting them to be slow as Flash or faster. The flash version can be played here: http://elrinconde-ex.blogspot.com/2012/ ... iewer.html
I'm attaching the love file, if someone can help me to optimize this it would be great, I can be missing something really obvious.
Is Flash/AS3 faster than Lua?
Is Flash/AS3 faster than Lua?
- Attachments
-
- mandelbrot.love
- (4.02 KiB) Downloaded 149 times
Re: Is Flash/AS3 faster than Lua?
depends on what you're doing in terms of c calls; currently luajit can't compile c function calls that have been bound with the regular lua c api, which will result in a trace abort: that call and likely a fair bit of other code in that path will run interpreted. if you're drawing pixels individually, then ouch (even if it could compile those, it's still going through the c api which is going to have quite some overhead for setting pixels)
you'd have to use luajit's v and/or dump modules to get a better understanding of what is and isn't being compiled. if love exposes a way to set imagedata based on a table's contents then that might help quite a bit, since that would cut down on a hell of a lot of c calls (this would help the standard lua version a lot too, i'd imagine).
ideally, a luajit version of love would actually be implemented as much as possible in lua, using luajit's ffi for all c calls apart from the standard library (as c calls done through the ffi are at least compilable [except for uncommon variants, maybe])
EDIT: just for shits i v'd it
those NYIs are killers
you'd have to use luajit's v and/or dump modules to get a better understanding of what is and isn't being compiled. if love exposes a way to set imagedata based on a table's contents then that might help quite a bit, since that would cut down on a hell of a lot of c calls (this would help the standard lua version a lot too, i'd imagine).
ideally, a luajit version of love would actually be implemented as much as possible in lua, using luajit's ffi for all c calls apart from the standard library (as c calls done through the ffi are at least compilable [except for uncommon variants, maybe])
EDIT: just for shits i v'd it
Code: Select all
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- inner loop in root trace at main.lua:147]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:132 -- NYI: C function 0x02afe0a0 at main.lua:167]
[TRACE --- main.lua:143 -- leaving loop in root trace at main.lua:160]
[TRACE --- main.lua:133 -- blacklisted at main.lua:143]
[TRACE --- main.lua:132 -- blacklisted at main.lua:143]
[TRACE --- main.lua:132 -- blacklisted at main.lua:143]
[TRACE --- main.lua:132 -- blacklisted at main.lua:143]
[TRACE --- "boot.lua":387 -- leaving loop in root trace at "boot.lua":401]
[TRACE --- "boot.lua":383 -- NYI: C function 0x02b04218 at "boot.lua":386]
[TRACE --- main.lua:403 -- NYI: C function 0x02b04a88 at main.lua:404]
[TRACE --- "boot.lua":387 -- leaving loop in root trace at "boot.lua":401]
[TRACE --- "boot.lua":383 -- NYI: C function 0x02b04218 at "boot.lua":386]
Re: Is Flash/AS3 faster than Lua?
Yes, I also think the problem is the constant trespassing of the Lua/C++ barrier to draw every pixel.
To be fair Flash version is using a BitmapData structure (AS3 has bytearray structures) so I'm drawing the pixels directly to the bitmap for later rendering.
I was looking for, but couldn't find something like that in Love. I can be wrong, though.
This seems a nice place to modify Lua, let me check.
To be fair Flash version is using a BitmapData structure (AS3 has bytearray structures) so I'm drawing the pixels directly to the bitmap for later rendering.
I was looking for, but couldn't find something like that in Love. I can be wrong, though.
This seems a nice place to modify Lua, let me check.
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Is Flash/AS3 faster than Lua?
Why not use a shader?
Re: Is Flash/AS3 faster than Lua?
to be honest, I don't know where to start to create a mandelbrot fractal shader in Love, it's easy?slime wrote:Why not use a shader?
Re: Is Flash/AS3 faster than Lua?
You definitely should use a shader:_ex_ wrote:to be honest, I don't know where to start to create a mandelbrot fractal shader in Love, it's easy?slime wrote:Why not use a shader?
- Löve is hardware accelerated, meaning iterating pixels on the screen isn't it's purpose.
There was a thread aboutfound it - Löve is a very easy way to start learning about shaders: a lot of cool examples in this thread
also bonus for all you android users
Who is online
Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 3 guests