Git Product home page Git Product logo

Comments (7)

mame avatar mame commented on July 1, 2024

Thank you, interesting! I'll try later.

from optcarrot.

headius avatar headius commented on July 1, 2024

I forgot to say thank you for coming up with an interesting way to measure Ruby performance! I'll spend some time playing with this and see what we can improve. Obviously I'll try to get the case/when optimization in first :-)

from optcarrot.

mame avatar mame commented on July 1, 2024

@headius I have updated jruby benchmark results with using -Xcompile.invokedynamic=true. Now it matches MRI 2.3 in the default mode.

Also confirmed 9.1.0.0-SNAPSHOT. It marks 35 fps on my machine, while MRI 2.3 marks 26 fps. Great! I like to add it to the list when it is officially released.

Note we have still not yet made homogeneous case/when O(1).

I think the default mode now uses no big case statement. So, parhaps, case/when O(1) optimization will have less effect for the default mode.

For the moment, this optimization does not fit JRuby's model of execution.

--opt is just my playground to explore promising optimizations for MRI. So, never mind. I think a good Ruby implementation runs faster the default mode, without having to use a dirty hack such as manual method inlining.

from optcarrot.

headius avatar headius commented on July 1, 2024

--opt is just my playground to explore promising optimizations for MRI. So, never mind. I think a good Ruby implementation runs faster the default mode, without having to use a dirty hack such as manual method inlining.

It may be interesting to come up with a similar flag for JRuby that avoids using language structures that have unfortunate side effects. For example, in order to support String#[](regexp) we must prepare space for a $~ slot that might be needed. This affects all calls to #[], even when $~ is not needed. A JRuby-specific workaround is to use Array#at, since no version of #at needs $~.

I'll have a look at the code and see if we can do anything to improve perf on JRuby and other impls.

from optcarrot.

mame avatar mame commented on July 1, 2024

This affects all calls to #[], even when $~ is not needed.

Heh. MRI does not do that. Is it difficult to allocate the slot on demand?

A JRuby-specific workaround is to use Array#at, since no version of #at needs $~.

Hmm. Unfortunately, it is not trivial to replace Array#[] with #at because this program highly uses polymorphism of Method#[] and Array#[].

To implement memory-mapped I/O, this program represents a memory read as mem[addr][addr]. If the address is a normal memory cell, mem[addr] returns an Array (raw memory) and then mem[addr][addr] returns a stored value. If the address is memory-mapped I/O (a trigger of circuit events), mem[addr] returns a Method object and then mem[addr][addr] invokes the event. So, it is difficult to replace #[] with #at systematically. I may try later manually.

from optcarrot.

headius avatar headius commented on July 1, 2024

Heh. MRI does not do that. Is it difficult to allocate the slot on demand?

At the moment, there's nothing to really "allocate" but we have to bump a frame pointer on the way in and out of any method with [] because we can't see downstream calls at that point to know if it's String#[](regexp) or not. That in turn requires some deoptimization of other aspects (most obviously, we can't omit the frame logic).

It's a worthwhile thing for us to improve, however, so we are continuing to explore options.

from optcarrot.

mame avatar mame commented on July 1, 2024

Congrats to the release of JRuby 9.1.0.0! I'll update the benchmark result next week.

from optcarrot.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.