-
Notifications
You must be signed in to change notification settings - Fork 325
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
Equality with conversions #9070
Equality with conversions #9070
Conversation
engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java
Show resolved
Hide resolved
.../runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsAtomNode.java
Show resolved
Hide resolved
There are currently failures in EnsoMultiValue conversions. Looks like the tests need to be updated to the new behavior: bbbbf73 |
First benchmark results are here and at least the |
engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java
Show resolved
Hide resolved
f33faad
to
69510cd
Compare
Second run of benchmarks seem to indicate |
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.
LGTM. Please, don't forget to provide some docs somewhere how the equality works now. It's starting to get really complex.
engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java
Outdated
Show resolved
Hide resolved
} catch (ArityException ex) { | ||
var assertsOn = false; | ||
assert assertsOn = true; | ||
if (assertsOn) { |
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.
Why not just panic here? ArityException
is unexpected here, no? So it should result in some IllegalStateException
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.
The answer is probably the same as in the previous discussion about the topic.
...untime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsSimpleNode.java
Show resolved
Hide resolved
...ntime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsComplexNode.java
Show resolved
Hide resolved
...untime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsSimpleNode.java
Show resolved
Hide resolved
Fixes the regression introduced by #9070 in `org.enso.benchmarks.generated.Collections.list_meta_fold` benchmark. # Important Notes As can be seen on the graph in IGV: ![image](https://github.com/enso-org/enso/assets/14013887/31b6ceca-4909-4a8f-987f-b456b3fb0a1b) For some reason, `EqualsSimpleNode` is POLYMORPHIC. That seems to be the most visible performance problem. First, I tried to introduce `ConditionProfile` with: ```diff diff --git a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java index b368fb7fe..57274b37e 100644 --- a/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java +++ b/engine/runtime/src/main/java/org/enso/interpreter/node/expression/builtin/meta/EqualsNode.java @@ -9,6 +9,7 @@ import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.interop.ArityException; import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.profiles.ConditionProfile; import org.enso.interpreter.dsl.AcceptsError; import org.enso.interpreter.dsl.BuiltinMethod; import org.enso.interpreter.node.EnsoRootNode; @@ -46,6 +47,7 @@ public final class EqualsNode extends Node { @child private EqualsSimpleNode node; @child private TypeOfNode types; @child private WithConversionNode convert; + private final ConditionProfile equalsProfile = ConditionProfile.create(); private static final EqualsNode UNCACHED = new EqualsNode(EqualsSimpleNodeGen.getUncached(), TypeOfNode.getUncached(), true); @@ -85,7 +87,7 @@ public final class EqualsNode extends Node { public boolean execute( VirtualFrame frame, @AcceptsError Object self, @AcceptsError Object other) { var areEqual = node.execute(frame, self, other); - if (!areEqual) { + if (!equalsProfile.profile(areEqual)) { var selfType = types.execute(self); var otherType = types.execute(other); if (selfType != otherType) { ``` But that did not resolve the issue. My second attempt was to enable splitting for `EqualsSimpleNode` with `@com.oracle.truffle.api.dsl.ReportPolymorphism` annotation, which seems to resolve the issue. The benchmark is back to its original score, and `EqualsSimpleNode` is no longer POLYMORPHIC.
Pull Request Description
Fixes #8855 by providing support for
==
between different types with conversions.Checklist
Please ensure that the following checklist has been satisfied before submitting the PR:
Scala,
Java,
style guides.
==
andhash
code: ecd4b90