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

Remove TailCall.TailPosition.NotTail metadata. #11303

Merged
merged 5 commits into from
Oct 11, 2024

Conversation

Akirathan
Copy link
Member

@Akirathan Akirathan commented Oct 10, 2024

Pull Request Description

TailCall.TailPosition.NotTail metadata is attached to every IR element that is not in tail position. Which is true for most IR elements. This is inefficient and unnecessary. This PR removes this metadata and keeps only TailCall.TailPosition.Tail. This removes few bytes from MetadataStorage from most of IR elements

Important Notes

To check whether ir element is not in tail position, we used to check it with something like this ir.getMetadata(TailCall) == Some(TailCall.TailPosition.NotTail), now, we simply can do it with ir.getMetadata(TailCall) == None

Checklist

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

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.

If IR element is not in tail position, there is simply no metadata.
@Akirathan Akirathan added CI: No changelog needed Do not require a changelog entry for this PR. CI: Clean build required CI runners will be cleaned before and after this PR is built. labels Oct 10, 2024
@Akirathan Akirathan self-assigned this Oct 10, 2024
Comment on lines +216 to +223
private def updateMetaIfInTailPosition[T <: IR](
isInTailPosition: Boolean,
ir: T
): T = {
if (isInTailPosition) {
ir.updateMetadata(TAIL_META)
} else {
ir
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the gist of this PR. There is no NotTail attached anymore.

@Akirathan Akirathan marked this pull request as ready for review October 10, 2024 16:08
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

Thank you for extracting the discovery you made while working on @Tail_Call mini passes and applying it for the benefit of size of .bindings caches. Have you measured the effect on the size of the caches? I'd assume it is at least five bytes per each non-tail statement. E.g. it might be a lot.

/** The expression is not in a tail position and cannot be tail call
* optimised.
*/
final case object NotTail extends TailPosition {
Copy link
Member

Choose a reason for hiding this comment

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

There is no NotTail anymore. TailPosition has only one instance and that's the case object Tail.

@Akirathan
Copy link
Member Author

Akirathan commented Oct 11, 2024

Have you measured the effect on the size of the caches? I'd assume it is at least five bytes per each non-tail statement. E.g. it might be a lot.

@JaroslavTulach I have not measured it. If you are interested, I will do the measurements, but for me, it is enough to know that it will definitely be smaller. However, I don't think the change will be that dramatic, because previously, the TailCall.TailPosition metadata was persisted as a simple boolean value (see https://github.com/enso-org/enso/blob/develop/engine/runtime-compiler/src/main/java/org/enso/compiler/pass/analyse/PassPersistance.java#L107).

GitHub
Hybrid visual and textual functional programming. Contribute to enso-org/enso development by creating an account on GitHub.

@Akirathan Akirathan added the CI: Ready to merge This PR is eligible for automatic merge label Oct 11, 2024
@mergify mergify bot merged commit d9b3c75 into develop Oct 11, 2024
42 checks passed
@mergify mergify bot deleted the wip/akirathan/remove-not-tail-meta branch October 11, 2024 11:17
@JaroslavTulach
Copy link
Member

Have you measured the effect on the size of the caches? I'd assume it is at least five bytes per each non-tail statement. E.g. it might be a lot.

If you are interested ... will do the measurements, but for me, it is enough to know that it will definitely be smaller.

In general I see 5% decrease in .bindings size. Base went down from 34MB to 32MB. The biggest effect is on Visualizations library:

  • before 3086432 bytes
  • after 2239275 bytes
  • smaller by 28%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. 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.

3 participants