4 ms·
"E.g. I'm working on an ahead-of-time Ruby compiler.... easy..." If you haven't already... it's 2015. You might want to go look at the sun-bleached bones of al
by jerf 11y ago
"E.g. I'm working on an ahead-of-time Ruby compiler.... easy..."
If you haven't already... it's 2015. You might want to go look at the sun-bleached bones of all your predecessors who confidently proclaimed that all the dynamic scripting languages were slow for no good reason and a JIT could totally just JIT all the slowness away.
If it's a journey you wish to take, by all means, be my guest, but, please, be sure you know what you're getting into.
(The aforementioned sun-bleached bones are the bulk of the reason why I no longer believe in the old adage that "languages don't have performance characteristics, only implementations do", at least in the full sense intended. Languages may not have performance characteristics but the evidence rather strongly suggests they can put upper bounds on performance.)
- vidarh 11y agoYour contraction massively misrepresents what I wrote. Compiling Ruby is by no means easy. And optimizing it to similar speed as e.g. C is massively hard. But optimizing the dynamic dispatch down to the cost of a vtable call is trivially easy.
- jerf 11y ago"Your contraction massively misrepresents what I wrote." Yeah, sort of, but it represents what I was trying to say accurately enough. You will find, as you go through your project, that nothing is "trivially easy" when it comes to JIT'ing Ruby, and, alas, "just compile it down to a vtable call" is likely to not be that easy either. Dynamic language JITs have a terrible recursive 90/10 problem. In fact I doubt that it actually will be that simple because if it were, PyPy would be a great deal faster than it is. (From a JIT perspective, Ruby and Python are all but identical.) The point I'm making is not that you shouldn't do this. The point is that A LOT of people have ALREADY done this, and it has proved to be a lot harder than any of them thought, and you really ought to take some time to go study PyPy or various PHP JIT projects before getting too excited about thinking that you are going to speed Ruby up as much as you think you are. Particularly have a look at RPython. If you are going to tackle this project, this notorious Zeno tarpit [1], I recommend everyone do it with eyes open. No, it isn't going to be as easy as "just do X", or it would already have been done. [1]: http://esr.ibiblio.org/?p=6772 http://esr.ibiblio.org/?p=6772
- vidarh 11y ago> nothing is "trivially easy" when it comes to JIT'ing Ruby First of all, I'm not JIT'ing Ruby. Secondly, a lot of things are "trivially easy" when it comes to compiling Ruby - even ahead of time. I know, because while there's lots of outstanding bits, I am compiling a reasonable subset, and I understand the remaining tradeoffs well enough to know where the pitfalls are - it's by no means my first compiler > The point is that A LOT of people have ALREADY done this A lot of people have done this, but despite decades of history of optimisation of dynamic languages, most of them appears to not have bothered with even a cursory look at the literature. In terms of JIT, the Truffle backend for JRuby is a good example of the difference actually applying modern techniques makes.
- WalterGR 11y agoYou might want to go look at the sun-bleached bones of all your predecessors who confidently proclaimed that all the dynamic scripting languages were slow for no good reason and a JIT could totally just JIT all the slowness away. I ask this with the best of intentions: where can I learn more about this? (FWIW, I'm curious specifically about the ways in which Common Lisp (or Lisps in general) does or does not avoid the performance pitfalls of - say - Ruby or Python. But I'm definitely interested in the general topic as well...)
- chrisseaton 11y agoIf you are coming from the perspective of a Ruby programmer, there are lots of papers on optimising Ruby in the Bibliography http://rubybib.org http://rubybib.org. But what you want to do is take a look at a few of the VM papers there, and then look at their references and see what people have tried previously. The related work sections often talk about previous limitations. Lisps in general are much more static than a language like Ruby, so it wouldn't be very instructive to compare against them. The trickiest Ruby features are things like Proc#binding and Kernel#set_trace_func, as these require you to modify running code and data structures which may have already been very aggressively modified. I don't think (but am not an expert) that most Lisps have features like those. Lisps have code as data of course, which sounds like a nightmare to compile, but it's really not - the code trees are immutable (I believe) when generated, so just compile them whenever you see a new tree root and cache.
- tokenrove 11y agoFeatures like generic dispatch in Common Lisp result in similar amounts of dynamism; methods and classes can be defined and redefined at any time so a lot of work goes into making that fast; see for example http://metamodular.com/generic-dispatch.pdf http://metamodular.com/generic-dispatch.pdf Also similar to Kernel#set_trace_func, CL has TRACE (http://www.lispworks.com/documentation/lw61/CLHS/Body/m_tracec.htm http://www.lispworks.com/documentation/lw61/CLHS/Body/m_trac...) but unlike generic dispatch, that's not expected to be fast.
- vidarh 11y ago