Skip to content
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

Propagate comparator warnings via Any.== #11009

Merged
merged 13 commits into from
Sep 25, 2024
Merged

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Sep 9, 2024

Pull Request Description

Fixes #10679 by changing the return type of EqualsXyzNodes to EqualsAndInfo. This class holds the result of the comparation as well as any attached warnings. EqualsBuiltinNode then re-attaches the warnings, if there are any.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Sep 9, 2024
@JaroslavTulach JaroslavTulach self-assigned this Sep 9, 2024
@GregoryTravis
Copy link
Contributor

These tests should pass now.

@JaroslavTulach
Copy link
Member Author

There is 21 failing tests in Table_Tests what do you think about them, @GregoryTravis?

@GregoryTravis
Copy link
Contributor

There is 21 failing tests in Table_Tests what do you think about them, @GregoryTravis?

The failures say first difference at index Nothing, which is an error I have not seen before.

@JaroslavTulach
Copy link
Member Author

These tests should pass now.

These tests pass after 445e500

@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Sep 11, 2024

Engine benchmarks run is finished. Here are potential problems:

  • AtomBenchmarks_benchGenerateListQualified slightly slower
  • IfVsCaseBenchmarks_caseBench3 - improved!
  • RecursionBenchmarks_benchNestedThunkSum slightly slower
  • RecursionBenchmarks_benchSumStateTCO slighlty slower
  • TypePatternBenchmarks_matchOverAny minimal regression
  • TypePatternBenchmarks_matchOverDecimal minimal regression
  • etc.

Update on Sep 25, 2024: The benchmarks regression should now be eliminated with 2c4b522 to be verified by engine benchmarks run.

Copy link
Member

@Akirathan Akirathan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the introduction of the new EqualsAndInfo return type. Why can't EqualsNode.execute just return Object and for some specializations that should return a result with warnings just return WithWarnings object, and for other a boxed Boolean? Introduction of EqualsAndInfo adds an inconsistency to how we manipulate with warnings.

@jdunkerley
Copy link
Member

Approved the enso tests to allow it to proceed.

@JaroslavTulach
Copy link
Member Author

I don't like the introduction of the new EqualsAndInfo return type.
Why can't EqualsNode.execute just return Object and for some specializations that should return a result with warnings just return WithWarnings object, and for other a boxed Boolean?

Such an approach has been tried already. Please see this diff: #10679 (comment) - there are few problems to it:

Checking the result becomes more complicated. The above patch is using instanceof Boolean, but that's wrong. The code would probably deserve its own nodes: CheckBooleanNode and RewrapWarningFromBooleanNode, etc. Given the majority of use-cases (EqualsBuiltinNode``HashMap and comparator) are built around really need the boolean use-case it seems inefficient to wrap and immediately unwrap the value.

Warnings aren't efficient. Given 99.9% of use-cases is going to work with boolean only, having all the machinery in place for warnings manipulation is an over kill. It should be conditional. The current PR does that by checking equals() and making a decision. Checking warnings() aren't null and rewriting itself to handle the complicated case. No WarningsLibrary, no AppendWarningNode until a boolean with warning appears.

Introduction of EqualsAndInfo adds an inconsistency to how we manipulate with warnings.

A bit. But EqualsNode is special. It is not an expression! We have EqualsBuiltinNode now to represent an expression. EqualsNode is there to check == and give you EqualsAndInfo - EqualsBuiltinNode than extracts such info and converts it into regular EnsoObject.

I don't expect too much code in Enso to use EqualsNode directly. The EqualsBuiltinNode is one. The HashMap package is the other. The comparator is the 3rd. Maybe we can move the EqualsNode "family" into own package to demonstrate it is "special"?

@JaroslavTulach
Copy link
Member Author

Benchmarks seem to be fine. One good result on bankers, @GregoryTravis:

bankers

@JaroslavTulach JaroslavTulach added the CI: Ready to merge This PR is eligible for automatic merge label Sep 25, 2024
@mergify mergify bot merged commit f37e50e into develop Sep 25, 2024
42 checks passed
@mergify mergify bot deleted the wip/jtulach/EqualsAndInfo10679 branch September 25, 2024 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comparator warnings should propagate to output of ==
4 participants