Skip to content

Conversation

@bezirg
Copy link
Contributor

@bezirg bezirg commented Aug 29, 2021

A new PIR.letfloat pass that floats maximally outwards (a.k.a. full laziness).

The algorithm is influenced by "Let-floating: moving bindings to give faster programs",
where the authors also make use of the free term&type variables of to-float lets to calculate their maximum floating position.
Unlike their approach, we apply this floating transformation in a global fashion ; unlike their source language (ghc-core), we have to make sure not to float any effectful lets.

Pre-submit checklist:

  • Branch
    • Tests are provided (if possible)
    • Commit sequence broadly makes sense
    • Key commits have useful messages
    • Relevant tickets are mentioned in commit messages
    • Formatting, materialized Nix files, PNG optimization, etc. are updated
  • PR
    • Self-reviewed the diff
    • Useful pull request description
    • Reviewer requested

@bezirg bezirg force-pushed the bezirg/newletfloat branch 4 times, most recently from 596578f to fd416eb Compare September 1, 2021 14:54
@michaelpj michaelpj requested a review from jakzale September 2, 2021 10:19
@michaelpj
Copy link
Contributor

(Requesting a review from Jakub, fo when Nikos thinks this is ready to look at!)

@bezirg bezirg force-pushed the bezirg/newletfloat branch from 0fa32ac to 7bef1a1 Compare September 3, 2021 13:51
@bezirg bezirg marked this pull request as ready for review September 3, 2021 13:53
@bezirg bezirg requested a review from jakzale September 3, 2021 13:54
@bezirg bezirg force-pushed the bezirg/newletfloat branch 3 times, most recently from fc86b27 to 1f6e84a Compare September 3, 2021 18:44
@bezirg bezirg force-pushed the bezirg/newletfloat branch from 14d3a07 to cd108d4 Compare September 4, 2021 07:46
@bezirg bezirg self-assigned this Sep 4, 2021
@bezirg bezirg force-pushed the bezirg/newletfloat branch from cd108d4 to 52c8fb8 Compare September 4, 2021 08:51
@bezirg bezirg changed the title Bezirg/newletfloat SCP-2693: Bezirg/newletfloat Sep 4, 2021
@bezirg bezirg force-pushed the bezirg/newletfloat branch from 52c8fb8 to 8aab0d4 Compare September 4, 2021 08:55
@bezirg bezirg changed the title SCP-2693: Bezirg/newletfloat SCP-2693: New PIR.LetFloat Sep 4, 2021
Copy link
Contributor

@jakzale jakzale left a comment

Choose a reason for hiding this comment

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

I have added some minor comments and possible improvements to how Pos is handled.

Looks good. My only concern is that after reading the file multiple times I still do not completely grok how the floating works...

Copy link
Contributor

@michaelpj michaelpj left a comment

Choose a reason for hiding this comment

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

Still reviewing the floating back. Along the way, I did the writer transformation because I wanted to check that it would actually work 😅 which it does. I pushed the commits to this branch but. Feel free to take it or do something else.

makeNewLet :: NE.NonEmpty (LetNaked tyname name uni fun a) -> Term tyname name uni fun a -> Term tyname name uni fun a
makeNewLet floatableNaked =
-- arbitrary: use the annotation of the first let of the floated lets as the annotation of the new let
-- TODO: use some semigroup annotation-joining instead
Copy link
Contributor

Choose a reason for hiding this comment

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

do it!

@michaelpj
Copy link
Contributor

Okay, basically LGTM!

Forgot to recurse the removeLets inside the rhs bindings

WIP: separated depth and scope reader

WIP: fixed remaining bugs

NewLetFloat: fixed accumulating letholes, fixed depth-calc of mark

Fixed floatBack to recurse inside the floated-lets rhs'es

Don't store the Recursivity for LetHoles

NewLetFloat: when calculating freevars look into bindings' types

Clean up, refactor

More refactoring

Changed from unmovable to floatable

Formatting

Rewrite removeLets to use Writer

Rewrite mark to use Writer

Make MarkCtx a datatype

Make Pos a datatype

PR adressing

semigroup annotation joining

update nix+fixstylishhaskell
@michaelpj
Copy link
Contributor

Succeeded on all the linux jobs, let's just merge this.

@michaelpj michaelpj merged commit 73b21ed into master Sep 14, 2021
awkure pushed a commit to mlabs-haskell/plutus that referenced this pull request Sep 15, 2021
Forgot to recurse the removeLets inside the rhs bindings

WIP: separated depth and scope reader

WIP: fixed remaining bugs

NewLetFloat: fixed accumulating letholes, fixed depth-calc of mark

Fixed floatBack to recurse inside the floated-lets rhs'es

Don't store the Recursivity for LetHoles

NewLetFloat: when calculating freevars look into bindings' types

Clean up, refactor

More refactoring

Changed from unmovable to floatable

Formatting

Rewrite removeLets to use Writer

Rewrite mark to use Writer

Make MarkCtx a datatype

Make Pos a datatype

PR adressing

semigroup annotation joining

update nix+fixstylishhaskell

Co-authored-by: Nikolaos Bezirgiannis <[email protected]>
jonesnoaht pushed a commit to jonesnoaht/plutus that referenced this pull request Oct 8, 2021
Forgot to recurse the removeLets inside the rhs bindings

WIP: separated depth and scope reader

WIP: fixed remaining bugs

NewLetFloat: fixed accumulating letholes, fixed depth-calc of mark

Fixed floatBack to recurse inside the floated-lets rhs'es

Don't store the Recursivity for LetHoles

NewLetFloat: when calculating freevars look into bindings' types

Clean up, refactor

More refactoring

Changed from unmovable to floatable

Formatting

Rewrite removeLets to use Writer

Rewrite mark to use Writer

Make MarkCtx a datatype

Make Pos a datatype

PR adressing

semigroup annotation joining

update nix+fixstylishhaskell

Co-authored-by: Nikolaos Bezirgiannis <[email protected]>
@kwxm kwxm deleted the bezirg/newletfloat branch February 2, 2022 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants