-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JRuby is super-slow to execute a big and trivial case-when statement #3672
Comments
Is this documented somewhere? How does it interact with the existing semantics that cases are tried sequentially with If MRI does this then it's a language feature, not an optimisation, and it needs to be covered by the specs. |
@mame we have some plans to reintroduce this at a later date. JRuby 1.7.x does a jump table for Fixnums and a couple of other simple types. We have not added them to 9k yet but we will at some point. |
Since this is an implementation detail of MRI, I don't think this behavior is documented anywhere.
I think you meant BTW, I have no intention to force you to do the same. This is just a suggestion. |
@enebo Ah, do you mean this optimization has been already implemented but disabled for any reason? If so, sorry for noise. Thank you! |
@mame it was not disabled, but we have a completely new runtime in JRuby 9000 so we could not just port the old optimization over as-is. |
I understand very well. I'll try JRuby 1.7. Should I close this issue? May I leave it to you? Thank you very much! |
We have an open issue for remaining optimizations in case/when, so we'll close this. See #3513. |
Reopening this as the better bug for ongoing optimization work. |
FYI: I published my program and benchmark result. |
@mame thanks for the link. We will be sure to reexamine the performance periodically and also once we re-add some jumptable optimizations. |
@mame I have implemented constant-time Fixnum case/when but I'm getting a strange error running the --opt version of optcarrot:
Two questions:
|
Benchmark of 100 all-Fixnum cases (1000 does not JIT and remains interpreted):
@mame @ko1 Can you point me toward the constant-time case/when optimization in MRI? I'd like to match it for JRuby 9.1. |
@nobu You may know where this optimization is in MRI too... |
There are some points in compile.c and insns.def. |
@nobu: Great, thanks! |
No fiber is used in the generated code. Maybe your jruby failed to generate a correct source code.
Try |
Continuing work in post 9.1. |
Fixnum case optimizations have been merged to master. Remaining work bumped to 9.1.4.0. |
General problem with large case statements preventing JIT. I'm detargeting. |
There's nothing specific to JRuby will optimize homogeneous case/when to a jump table in at least the Fixnum case, so we'll call this one done as of 9.1.4.0. |
Hello,
MRI adopts "jump table"-like optimization for case-when statement if all clauses have trivial immediate values such as Integer and Symbol. How about implementing this optimization in JRuby?
Thank you,
The text was updated successfully, but these errors were encountered: