[MacRuby-devel] experimental branch: status update
Laurent Sansonetti
lsansonetti at apple.com
Sun Apr 12 23:01:17 PDT 2009
Another week, another status update on the experimental branch!
Unfortunately, the work done this week was pretty light.
- More work on IO (IO#readlines, IO#each_byte and IO#each_char).
- A better implementation for catch/throw was added.
- Tail-call elimination was introduced. This optimization transforms
recursive calls into local loops, in order to prevent stack overflows.
As an example, the following code snippet works on the experimental
branch, but doesn't on trunk (or the regular Ruby implementation).
$ ./miniruby -e "def f(n); return if n == 0; f(n-1); end; f(1000000)"
In order to benefit of this optimization, the recursive call must be
performed at the very end of one of the function's blocks, which means
the programmer will most likely need to rewrite his algorithms.
- Symbol comparisons (#==, #!= and #===) are now inlined if both
operands are constants. The bm_vm2_case.rb benchmark is now running
faster than YARV.
$ ruby b.rb benchmark/bm_vm2_case.rb
benchmark/bm_vm2_case.rb
MacRuby version 0.5 (ruby 1.9.0) [universal-darwin9.5, x86_64]
0.20079
0.202569
0.210689
ruby 1.9.1 (2008-12-28 patchlevel-5000 trunk 21107) [i386-darwin9.5.0]
0.680986
0.676041
0.679767
A funny fact that we discovered during this change was that Ruby 1.9
does not check if #=== has been overwritten in case symbols are used
in a case expression. http://redmine.ruby-lang.org/issues/show/1376
- A new JIT compilation strategy was developed, which basically
compiles methods at the very last moment, right before the runtime
actually needs them. The strategy is now mostly stable modulo 1 bug
that I still need to investigate and fix, which is why it is not
enabled by default. If you want to play with it, you need to enable
the ROXOR_ULTRA_LAZY_JIT constant in roxor.cpp.
- Vincent started working on a spec regarding 1.9 string encodings!
- The LLVM IR interpreter was investigated in order to interpret
faster #eval expressions. The result of this investigation has been
committed and works pretty well with simple expressions, however it is
not activated by default yet because of limitations when it comes to
call the VM primitives. We will have to modify the LLVM interpreter a
little bit in order to fully use it from MacRuby. This will be done in
the near future.
- The parsing process has been accelerated, principally we are doing
much less IOs and creating much less temporary objects.
As a result of a few of these changes (lazy JIT + new parsing
process), IRB starts a little less than 2 times faster on the machine
I'm using to write this message.
$ time ./miniruby_old -I./lib bin/irb -v
irb 0.9.5(05/04/13)
real 0m1.790s
user 0m1.586s
sys 0m0.278s
$ time ./miniruby -I./lib bin/irb -v
irb 0.9.5(05/04/13)
real 0m0.980s
user 0m0.941s
sys 0m0.114s
While this is a good progress, this is still not acceptable and the
startup time should be decreased by another 50% at the very least.
Hopefully there are still numerous things that we can do to achieve
this goal.
Laurent
More information about the MacRuby-devel
mailing list