-
Notifications
You must be signed in to change notification settings - Fork 326
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
Implement Number.round as a builtin #7460
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few suggestions to make the code more ready for partial evaluation (PE). However I am not sure applying my advises will be enough. We have to use IGV to investigate the compiler internals. Please rewrite the benchmarking code to be ready for such analysis.
...ime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/RoundNode.java
Outdated
Show resolved
Hide resolved
...ime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/RoundNode.java
Outdated
Show resolved
Hide resolved
...ime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/RoundNode.java
Outdated
Show resolved
Hide resolved
...ime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/RoundNode.java
Outdated
Show resolved
Hide resolved
...ime/src/main/java/org/enso/interpreter/node/expression/builtin/number/decimal/RoundNode.java
Outdated
Show resolved
Hide resolved
I am getting a NPE:
CCing @Akirathan. |
Yes. With @GregoryTravis, we established that the branch https://github.com/enso-org/enso/tree/numeric-bench-jmh is the one where the benchmarks on |
@Akirathan No need, it looks like converting to a builtin isn't going to be enough of an improvement so I'm going to close this. |
I solved the NPE - had some debris on my disk: With 665786c I can run for example:
|
I found a serious problem in the previous implementation, @GregoryTravis: Have to use
I believe the builtin is always faster. |
After 94dac30 I get the logic down to something like this: That looks simple enough - almost everything is a constant ( |
...rc/main/java/org/enso/interpreter/node/expression/builtin/number/smallInteger/RoundNode.java
Outdated
Show resolved
Hide resolved
It's really interesting that there is little change for Integer, and both here and in Table. Did you check what the result vectors in these benchmarks look like? Do they surely compute the right thing? Code looks ok, but definitely needs cleanup before merging (commented out code, unnecessary imports like |
+1
I've added some more changes for integers. In general it is hard to be faster for decimal places
e.g. the builtin and host Java interop operations are on par in this trivial case. The
|
My apologies, I hadn't merged properly and didn't have all of @JaroslavTulach 's changes. The benchmarks look good in both cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test for what happens if decimal_places
is not an Integer, or if use_bankers
is not Boolean? If not, please add one just to be sure it is handled correctly - it should throw a Type_Error
panic.
@JaroslavTulach @radeusgd I always keep the old implementation around for benchmarking until everything else is done and all review is finished, because bringing it back in repeatedly takes a lot of time, when there are unexpected changes. It seems to me that benchmarks are more reliable when they are run in the same execution, rather than running them separately at different branches -- I see more consistency in the comparison between the two implementations. |
Added test for type errors. |
Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.