-
-
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
Misc optz #3930
Misc optz #3930
Conversation
After a couple more profiling runs of red/black, here's the findings I've come up with:
The fixes in the PR have eliminated |
Moving on to another benchmark, Sampled profile shows heavy use of I was surprised how much of an impact! A patch to simply BEFORE
AFTER:
We need better mechanisms to know whether methods like Here's the patch. diff --git a/core/src/main/java/org/jruby/RubyNumeric.java b/core/src/main/java/org/jruby/RubyNumeric.java
index f606ca9..9642153 100644
--- a/core/src/main/java/org/jruby/RubyNumeric.java
+++ b/core/src/main/java/org/jruby/RubyNumeric.java
@@ -39,6 +39,7 @@ import org.jruby.anno.JRubyMethod;
import org.jruby.ast.util.ArgsUtil;
import org.jruby.common.RubyWarnings;
import org.jruby.exceptions.RaiseException;
+import org.jruby.ext.bigdecimal.RubyBigDecimal;
import org.jruby.javasupport.JavaUtil;
import org.jruby.runtime.Block;
import org.jruby.runtime.ClassIndex;
@@ -275,6 +276,22 @@ public class RubyNumeric extends RubyObject {
throw runtime.newTypeError("can't convert " + num.getType() + " into Float");
}
+ if (num instanceof RubyFloat) {
+ return num;
+ }
+
+ if (num instanceof RubyFixnum) {
+ return ((RubyFixnum) num).to_f();
+ }
+
+ if (num instanceof RubyBignum) {
+ return ((RubyBignum) num).to_f();
+ }
+
+ if (num instanceof RubyBigDecimal) {
+ return ((RubyBigDecimal) num).to_f();
+ }
+
return TypeConverter.convertToType(num, runtime.getFloat(), "to_f");
}
|
The patch above for |
Here's some numbers on pythag compared with other impls, for a current baseline. This includes my patch for
|
Er, that was "we need to find a better way to do dynamic calls from Java..." |
@headius thanks for these detailed write ups! |
I have merged latest master and committed the numericToFloat fix. I'll let it cook in CI and merge if it looks ok. |
Backed off the numeric optimization a bit. We'll get a better system in place for detecting core methods. |
I'm doing a few passes over our favorite benchmarks looking for things to fix. As of creation, this PR contains the following:
[]=
should require a frame. All other frame-aware method names compile as Call and not AttrAssign.BasicObject#!=
with a Ruby version, so it caches==
.These changes have a measurable effect on red/black, bringing average time per iter from high 0.4s to low 0.4s on 8u92.
More to come, probably.