Assembly output from JRuby 'fib'
Rémi Forax
forax at univ-mlv.fr
Thu Apr 28 09:18:01 PDT 2011
On 04/28/2011 04:27 PM, Christian Thalinger wrote:
> On Apr 28, 2011, at 3:56 PM, Charles Oliver Nutter wrote:
>> > On Thu, Apr 28, 2011 at 8:19 AM, Charles Oliver Nutter
>> > <headius at headius.com> wrote:
>>> >> I've been trying to think of ways to reduce the guard cost, since the
>>> >> perf without the JRuby guard is a fair bit better (0.79 versus 0.63s
>>> >> for fib(35)). The performance without guards is actually faster than
>>> >> any other Ruby implementation I've yet run. One idea:
>> >
>> > Now for a harder question...
>> >
>> > Any thoughts on how we can make this even faster? The bulk of the code
>> > seems to be taken up by a few operations inherent to Fixnum math:
>> >
>> > * Memory accesses relating to CallSite subclasses (LtCallSite and friends)
>> > * instanceof checks in those math-related CallSites
It should be class check ? not an instanceof check.
>> > * Fixnum overflow checks in + and - operations
Do you specialize the overflow check depending on the callsite ?
for fib(n - 1), you just have to check if n is different from
Integer.MIN_INT,
for fib(n - 2), if n is <= to Integer.MIN_INT - 1
and for + use the double xor tricks.
>> > * Fixnum allocation/initialization costs (or Fixnum cache accesses)
>> >
>> > As it stands today, the overhead of Fixnum operations is the primary
>> > factor preventing us from writing a lot more of JRuby's code in Ruby.
>> > Fixnums are too expensive to use for iterating over an array, doing a
>> > loop, etc. Of course we could do some code analysis to try to reduce
>> > loops to simple int operations, but barring that...does anyone have
>> > suggestions for reducing the cost of actual Fixnum operations?
> Sorry, that's not my area:-)
You should do what I'm doing with PHP.reboot.
The interpreter profile the dynamic type of the variable and
when you generate the code you typecheck the code to verifies
if the optimistic assumption are correct.
Compared to your dynopt approach, this means you don't have to
generate both codes. You generate the one with int + overflow checks
and if an overflow occurs, you escape (using invokedynamic)
to the code that works with Fixnum.
The tricky part is how to comeback ?
Rémi
More information about the mlvm-dev
mailing list