13 ms·
LuaJit 2.0 is out
- zdw 14y agoThere have also been a few changes in the roadmap for LuaJIT, as announced here: http://www.freelists.org/post/luajit/LuaJIT-Roadmap-20122013-UPDATE http://www.freelists.org/post/luajit/LuaJIT-Roadmap-20122013...
- dbaupp 14y agoChangelog: http://luajit.org/changes.html http://luajit.org/changes.html (extremely detailed)
- pdog 14y agoI understand that for LuaJIT 2.0, the whole VM has been rewritten. What's changed? What's new?
- dmpk2k 14y agoIf you're referring to LuaJIT 1 vs 2, the big differences are that LuaJIT 2 has a trace-tree JIT, and interpreters for each platform written in assembly. The improvement in performance is significant: LuaJIT2's interpreter alone is faster than LuaJIT1's JIT. It's hard to compare LuaJIT1 and 2, since LuaJIT2 is the most advanced JIT for a dynamically-typed language on the planet. The performance it can achieve with zero type annotations still blows me away.
- wesm 14y agoCareful, you might hurt some people's feelings. Has anyone done a systematic comparison of LuaJIT's performance with PyPy's?
- ltratt 14y agoYes, on synthetic benchmarks for LuaJIT-2.0.0-beta10 and PyPy 1.9. Those numbers need updating for the latest versions, but the basics are as follows. LuaJIT is incredibly fast to warm-up. On short benchmarks (around a second or less), it is way ahead of PyPy. As code runs for longer and longer, PyPy tends to catch up, and sometimes overtake, LuaJIT. My experience of RPython and PyPy suggests that there is a fair bit of scope for reducing some of the warm-up cost. I don't think PyPy will ever match LuaJIT's warm-up time, but it may well move quite a bit closer over time. It'll be interesting to see.
- nickik 14y agoAre you sure PyPy can overtake LuaJit after warmup. I think it can maybe do it in a micro benchmark but I doute that in a complex benchmark PyPy has any chance. LuaJit uses more advanced elimnation of loads and other optimications, also Lua is easier to optimize in generall. I dont know the numbers but I would really be astunished if that was true. Any way to of the cooles projects around.
- sirclueless 14y agoTo me, the real deciding factor that tells me that LuaJIT will win in the long run is that LuaJIT traces the high-level semantics of Lua, whereas PyPy has to work with Python bytecode, which may have a considerable amount of lost information. There are some good examples in the lambda-the-ultimate thread (for example, optimizing based on the knowledge that HLOAD and ASTORE will never alias). PyPy can't feasibly optimize the high-level Python AST, because the language is very large compared to Lua, and more or less behaviorally defined by Python's bytecode compiler.
- gruseom 14y agoThis is one of the interesting things about LuaJIT: it demonstrates the value of a small, well-designed language in a shockingly awesome way. The care that the Lua designers put into making Lua simple and regular is one of the reasons why a single programmer (a demigod, yes, but still — one demigod) is able to make so impressive an implementation.
- ltratt 14y ago> Are you sure PyPy can overtake LuaJit after warmup. I think it can maybe do it in a micro > benchmark but I doute that in a complex benchmark PyPy has any chance. When comparing the performance of different languages, micro benchmarks are about all we have, for better or worse. The best we can do is to run a fair number of different such benchmarks and make the comparison over them. I made my statement on the basis of such a comparison. Both LuaJIT and RPython / PyPy are very clever systems and there's a surprising amount of overlap between the way they do things. But every system has its own strengths and weaknesses, and it doesn't surprise me personally that neither one is a winner 100% of the time.
- driax 14y agoI don't think PyPy is faster. Their design is significantly more complicated and thus takes longer to tune. Additionally I think python is a small bit more dynamic then Lua, complicating things. I remember seeing a comparison between LuaJit and V8, both of which are highly tuned. LuaJit won on some of the benchmarks while V8 won others, and there were actually bit of a difference in the performance. That's the problem with Jitting, it's all tradeoffs. So what's good for a Jit in a browser is different from what's good in server environment. So you have to make a lot of benchmarks, testing widely different things, while at the same time not spending more time on optimizing one benchmark implementation in one language more than another.
- eslaught 14y agoI think you're forgetting the gold standard in dynamic languages from the 80s: Common Lisp. It's still around, and it's still faster than almost every other dynamically typed language out there. http://shootout.alioth.debian.org/u64/benchmark.php?test=all&lang=sbcl&lang2=gcc http://shootout.alioth.debian.org/u64/benchmark.php?test=all... Half of the benchmarks are less than a factor of 2x slower than C, which is better than even GHC can do for Haskell. Edit: Disclaimer: http://shootout.alioth.debian.org/dont-jump-to-conclusions.php http://shootout.alioth.debian.org/dont-jump-to-conclusions.p...
- CJefferson 14y agoThis code does do 'safety 0', which make lisp much closer to C (no array out-of-bounds checks, no int overflow checks among others). There is no need for LuaJIT to generate completely unsafe code to achieve it's performance.
- omaranto 14y agoWell, dmpk2k did say "with zero type annotations". How does SBCL fare without them?
- rayiner 14y agoPedantry: it's actually not a trace-tree JIT. It doesn't treat traces as trees. See: http://lambda-the-ultimate.org/node/3851#comment-57679 http://lambda-the-ultimate.org/node/3851#comment-57679
- nickik 14y agoYes. Thats a very importend point, its one of the majar diffrences between LuaJit and most other advanced trace jits. Also everybody should read that thread, at least once a year.
- tambourine_man 14y agoWhat an amazing thread. Thanks
- sshumaker 14y agoAlso the addition of the ffi library. It totally changes the way you integrate with C code (for the better) - its the best FFI I've seen in any language.
- erichocean 14y agoThe Factor FFI is pretty similar.
- spicyj 14y agoHuge congrats to Mike Pall on the release. The man is a machine when it comes to this sort of thing.
- alberth 14y agoHUGE congrats to Mike Pall. No amount of praise to him is enough. Hopefully, sponsors will continue to donate to this project to keep Mike fully employed and ensure long-term commitment of this project. I encourage sponsors to considered donating [1] On a side note, I wish the Programming Language Shootout [2] would add back in LuaJIT to demonstrate just how fast LuaJIT is in comparison to other languages. It's just amazing. [1] http://luajit.org/sponsors.html http://luajit.org/sponsors.html [2] http://shootout.alioth.debian.org/ http://shootout.alioth.debian.org/
- _casperc 14y agoAre there any other current benchmarks around for LuaJIT vs for instance java?
- alberth 14y agoWhen then Programming Language Shootout use to include LuaJIT, it had a benchmark against Java. If you want to see just LuaJIT vs Lua, [1] is a good comparison. The reason why I liked the inclusion of LuaJIT in the Programming Language Shootout was that it compared LuaJIT to other language implementations not just on speed, but memory consumption and lines of code. All of which, LuaJIT typically dominated. [1] http://luajit.org/performance_x86.html http://luajit.org/performance_x86.html
- abecedarius 14y agohttps://github.com/darius/superbench https://github.com/darius/superbench is not a big fancy cross-language shootout, at all, but I tried a few little programs I actually cared about. LuaJIT 'won' in the sense that of the languages I tried it had the best combo of performance and pleasant productivity, informally. I didn't try to quantify the latter. (Also, no Java because I wouldn't seriously consider it for hacking-for-fun.)
- alberth 14y agoWhere are the results of the benchmark?
- gavinlynch 14y agoSomething tells me there is an MC Hammer joke in here regarding being 2.0-Lua-Jit-To-Quit, but I'm not sure I can find the phrasing to excite the level of humor I was hoping for... Oh well, congrats on the release anyway! :)
- nickik 14y agoI wish I could understand LuaJit completly. I think if there is any (reasonably sized) software I would like to completly understand its this one. There is not only lots of good algorithms but also a lot of fantastic engineering. Things that you can not learn by reading papers. Congrats Mike Pall. Now lets see if you can do the same for GC community that you did to the JIT community. Good Luck.
- chubot 14y agoYeah I agree it's a very interesting piece of software. But do you understand the prequisites -- namely processor microarchitecture? I know that's why I don't understand it. I imagine if I did it might not be that hard to understand. Most people's knowledge of the stack stops somewhere around C. C hasn't changed for 40 years. It's a portable assembly language, i.e. the common mental model is that each construct in C is a handful of assembly instructions on any processor. But to get LuaJIT-type performance you have to understand exactly how the CPU works, i.e. pipelining and reordering, internal caching algorithms, internal branch prediction algorithms, and maybe to some extent multicore, although I guess LuaJIT is single-threaded like Lua. Mike Pall's mental model is for sure not C (since a lot of it isn't even written in C), but the lower level CPU architecture. And that has changed a lot in the last 10 years. I think even if you coded a lot of assembly language in the 80's it wouldn't necessarily translate to working on something like LuaJIT. My impression from skimming some online posts is that he has read hundreds of pages of Intel/ARM reference documentation from cover to cover, for multiple CPUs. I think there are a limited number of people with the patience to do that, since it's non-portable and changes relatively quickly. Another problem is I think that the open source tools that are available don't work at the right level. Like when you are running profilers, they are helping you profile assembly code generated by a C compiler. The performance characteristics he's taking advantage of are at a lower level. I think you need CPU-specific performance counters and so forth, and there's a different way of getting those for each make/model. Are there even open source tools that allow you to get this information? I'd appreciate a pointer. It's just a different level of abstraction than most programmers are working with. Not that many people are even writing "low level" C these days, e.g. something like redis. A lot of "application level" C code you see these days is old and/or not particularly fast. I would be interested if anyone has any pointers for this style of code other than "read a bunch of CPU manuals". :)
- mamcx 14y agoIs possible to use this for build a language? (I wanna to create my own language, but hope for something easier than LLVM, java, do it from zero in C)
- z3phyr 14y agoYeah people are trying to port clojure on LuaJIT.. It is possible.
- dmpk2k 14y agoI'm curious how they map Clojure's persistent data structures with many threads onto Lua states.
- nickik 14y agoClojure data structures do not have many threads. Clojure separates the form of the data and the way that they are processed. All Clojure Data Structures are completly feasable in a single threaded language.
- dmpk2k 14y agoThey're feasible, but a lot less interesting if you're not taking advantage of multiple cores.
- minikomi 14y agoWhat are people using LuaJit for in the wild? Particularly interested in Android integration - has anyone used it for any projects? From my admittedly small experience using it, I love the language, and would really like to use it in some way practically.
- StavrosK 14y agoI'm using it for http://www.instahero.com/ http://www.instahero.com/. Not mobile development, but I love the speed and sandboxing features.
- minikomi 14y agoThanks for the reply! How are you using it? With a lua web framework, or more low level stuff? edit: great looking site btw.
- StavrosK 14y agoThank you! I'm not developing the site in it, I'm using it for allowing the users to write their own analytics reports in an easy, fast and secure manner. It's just the bare LuaJIT interpreter with some simple libraries I'm developing for analyzing reports more efficiently.
- minikomi 14y agoAh, kind of like webscript.io! The sandboxing does seem to afford it a lot of cool use cases
- comex 14y agoI'd like to use Lua, partly to take advantage of LuaJIT and partly because it's an interesting language, but it drives me crazy that it lacks things like 'continue' and '+='. Maybe I should use MoonScript, but that completely discards Lua's aesthetics, which is hardly better.
- fuzzythinker 14y agomoonscript to the rescue! http://moonscript.org/reference/#update_assignment http://moonscript.org/reference/#update_assignment
- pheon 14y agomodify the luajit frontend. Added continue and != and some other weirder syntactic sugar, was only a half dozzen lines of code.
- catwell 14y agoLua 5.2 added "goto", which basically solves the lack of "continue". LuaJIT supports it too.
- moe 14y agoI wonder if a kickstarter could convince him to look at a Ruby VM ;)
- riffraff 14y agowell, he does have plans until luajit3... maybe we can book him in advance? I'd still like a fast ruby in five years :D
- ksec 14y agoMay be someone should work on Ruby to Lua instead? Using Lua and LuaJIT as a underlying languages. Like Coffescript to Javascript. That would be a lot faster then working on Ruby VM. And since Ruby 2.0's VM is still as slow as hell compared to LuaJIT