3 ms·
Is Lua currently even faster than JS and PHP, after all the effort that went into those languages’ optimizations?
by EGreg 2y ago
Is Lua currently even faster than JS and PHP, after all the effort that went into those languages’ optimizations?
- shakna 2y agoIt depends. In Debian's [0][1] benchmarks, JS is clearly ahead in a handful of the benchmarks, but in the rest, Lua is either on-par or faster. They're within a shout of each other. There are some places where Lua has surprisingly poor performance. However, in almost everything else, it's one of the fastest around. Luajit is still one of the fastest JITs in existence. In the real world, rather than constraints of a benchmark, Lua tends to be on-par from what I've seen. When you're not cold-cacheing everything, its memory use is lower. But it's standard library is ISO-C, and that's about it. No batteries. And the others beat it soundly there, whilst being close to the same performance. Which will mean they will just about always win out. [0] https://benchmarksgame-team.pages.debian.net/benchmarksgame/measurements/lua.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/... [1] https://benchmarksgame-team.pages.debian.net/benchmarksgame/measurements/node.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- igouy 2y ago> a handful of the benchmarks Now made a little easier for your comparison https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/node-lua.html https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
- Rochus 2y agoThanks. I calculated the geomean of the speed-up factors based on the average results (cpu secs) per benchmark. Overall, Lua 5.4.6 is factor 5.1 slower than V8 v23. Only in k-nucleotide Lua is slightly faster than V8, but in n-body Lua is even factor 26 slower. Btw. it seems notable that Lua 5.4.6 is about 40% slower than Lua 5.4.1, see http://software.rochus-keller.ch/are-we-fast-yet_Lua_results_2024-06-20.pdf http://software.rochus-keller.ch/are-we-fast-yet_Lua_results....
- nmz 2y agoMind you its a bit unfair to compare nodejs with lua, a better example is luajit.
- Rochus 2y agoSee https://news.ycombinator.com/item?id=42518508 https://news.ycombinator.com/item?id=42518508. LuaJIT was about factor two slower than the V8 in 2020.
- nmz 2y agoOf course, it doesn't have millions of dollars thrown at it.
- Rochus 2y agoIt's also a completely different approach. Probably additional performance could be gained by implementing JIT support for additional LuaJIT bytecodes. But we cannot predict how significant this gain would be. If the concept has limitations, more money likely doesn't change much. We can also compare with the old Mono 3 version developed by a rather small company (Xamarin, before they were bought by MS), which follows yet another approach than V8 or LuaJIT, and which achieves about the same performance as V8; see https://github.com/rochus-keller/Oberon/blob/master/testcases/Are-we-fast-yet/Are-we-fast-yet_results_linux.pdf https://github.com/rochus-keller/Oberon/blob/master/testcase....
- shakna 2y agoUnfortunately, the comparison pages don't actually show every test, or even the same run, as the main pages. You'll find a lot of differences between what I linked, and what is linked here.
- Rochus 2y agoI did performance measurements in 2020 based on the Are-we-fast-yet benchmark suite which combines micro and larger benchmarks. Here are the results: http://software.rochus-keller.ch/are-we-fast-yet_lua_results_2020-10-12.pdf http://software.rochus-keller.ch/are-we-fast-yet_lua_results... Overall, the JS/V8 version was twice as fast as the Lua/LuaJIT version. LuaJIT was only faster in the Mandelbrot benchmark. The recent PUC Lua version 5.4.1 is even ten times slower than the V8 version at the time. More recent V8 will likely be even faster. The results also demonstrate that one can get a pretty false impression when just looking at single microbenchmarks.