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

Removal of useless ApplicationSaturation phase #8181

Merged

Conversation

JaroslavTulach
Copy link
Member

@JaroslavTulach JaroslavTulach commented Oct 30, 2023

Pull Request Description

Work on #8172 has revealed that ApplicationSaturation phase of the IR compiler is kind of special. It pre-executes saturated applications help the compiler replace code with constants. While such IR compiler pass may be needed in a static compilation, it is very likely useless in dynamicaly compiled language like Enso. Let's verify it by removing the pass and checking effect of such change on benchmarks.

Checklist

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

  • All code follows the
    Scala,
    Java,
  • All code has been tested:
    • Remaining unit tests passing
    • Benchmark results remain unchanged

@JaroslavTulach JaroslavTulach self-assigned this Oct 30, 2023
@JaroslavTulach JaroslavTulach added the CI: No changelog needed Do not require a changelog entry for this PR. label Oct 30, 2023
@JaroslavTulach JaroslavTulach changed the title Wip/jtulach/any benefit of application saturation 6100 Removal of useless ApplicationSaturation phase Oct 30, 2023
@JaroslavTulach
Copy link
Member Author

JaroslavTulach commented Oct 30, 2023

Benchmark runs:

Comment on lines -117 to -118
ApplicationSaturation -->> ApplicationSaturation.Configuration(),
AliasAnalysis -->> AliasAnalysis.Configuration()
Copy link
Member

Choose a reason for hiding this comment

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

Was the ApplicationSaturation pass ever actually used outside of tests??

Looking at this initializer, we can see that the Configuration gets initialized with an empty Map for knownFunctions. And if the encountered funtion is not one of knownFunctions, it seems to always get the Unknown state, not influencing the codegen in any way.

I also don't see any other place where this pass is configured to "know" any functions and be able to do anything useful.

So I suspect we shouldn't see any difference in benchmarks, because we seem to be removing already practically unused code.

Copy link
Member

Choose a reason for hiding this comment

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

Looking at usages of the FunctionSpec, I cannot see anywhere in the codebase where it is constructed with the codegenHelper different than dummyFn (which does not do anything). So I really suspect this pass was never really fully used.

image

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.

Unused compiler pass? I had no idea we even had ApplicationSaturation. Good observation.

@JaroslavTulach
Copy link
Member Author

Benchmark runs:

* [engine benchmarks](https://github.com/enso-org/enso/actions/runs/6693072844) - seems OK, but [one more run](https://github.com/enso-org/enso/actions/runs/6695465210) scheduled to confirm that

* [stdlib benchmarks](https://github.com/enso-org/enso/actions/runs/6693078083) - the _stdlib benchmarks_ are clearly OK

Benchmarks seem to be unaffected. Merging.

@JaroslavTulach JaroslavTulach merged commit 3d23c6a into develop Oct 31, 2023
37 of 39 checks passed
@JaroslavTulach JaroslavTulach deleted the wip/jtulach/AnyBenefitOfApplicationSaturation_6100 branch October 31, 2023 05:20
@JaroslavTulach
Copy link
Member Author

A note by @kustosz:

Application saturation was an optimization pass that turned out to not actually optimize anything
So removing it is good

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants