-
Notifications
You must be signed in to change notification settings - Fork 483
UPLC Inliner: effect safety #7022
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
Conversation
f219e45
to
12ee913
Compare
12ee913
to
a6a86a2
Compare
a6a86a2
to
df45158
Compare
df45158
to
720affe
Compare
720affe
to
ae5c7ec
Compare
ae5c7ec
to
2be75be
Compare
9ae0492
to
ebf009b
Compare
I have disabled logs preservation in Marlowe validators and witnessed Ex Budget improvement:
|
plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Transform/Inline.hs
Show resolved
Hide resolved
plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Transform/Inline.hs
Outdated
Show resolved
Hide resolved
plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Transform/Inline.hs
Outdated
Show resolved
Hide resolved
plutus-core/untyped-plutus-core/src/UntypedPlutusCore/Transform/Inline.hs
Outdated
Show resolved
Hide resolved
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 title of the PR should mention UPLC, as you are only updating the UPLC inliner, not the PIR inliner.
plutus-core/testlib/UntypedPlutusCore/Test/Term/Construction.hs
Outdated
Show resolved
Hide resolved
-> String | ||
-> (Name, Name) | ||
uniqueNames2 n1 n2 = | ||
(name n1 0, name n2 1) |
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.
Second, this is a strange way of getting unique names. In most if not every other API (e.g., template haskell API, GHC API), getting uinque names is a monadic action. This way the names are truly unique. In your method, calling uniqueNames2 "a" "b"
the second time returns the same names, which are no longer unique.
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.
This is by design: reducing a uniqueness scope allows to get rid of the monadic context.
calling uniqueNames2 "a" "b" the second time returns the same names
We never call freshName "x"
more than once in tests anyway, so this is not a problem in practice.
OTOH the monadic contexts that requires to declare unique names before they are used is a (readability) problem that this approach solves.
`app` m | ||
`app` xs | ||
`app` i | ||
`app` b |
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.
Also: the heavy use of infix functions like `app`
looks visually unappealing.
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.
I guess its a matter of taste 🤷🏼♂️
I was thinking of having a variation of $
operator for infix applications, something like:
term
$. m
$. xs
$. i
$. b
but in the end app
is not so bad and doesn't require a creation/memoization of an extra operator.
|
||
{- | @(\a -> f (a 0 1) (a 2)) (\x y -> g x y)@ | ||
inlineImpure5 :: Term Name PLC.DefaultUni PLC.DefaultFun () | ||
inlineImpure5 = |
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.
Have you verified that before your change, the inliner won't inline this? I think that should be the case but it's worth verifying to be certain.
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.
Yes, I did.
inlineImpure5: FAIL
Test output was different from 'untyped-plutus-core/test/Transform/inlineImpure5.uplc.golden'.
It was:
\a -> (\b -> addInteger (addInteger 1 a) b) (addInteger 3 a)
Use -p '/simplify/&&/inlineImpure5/' to rerun this test only.
Also this should have a changelog entry. Please do not default to using the "no changelog required" tag. If you are in doubt about whether a changelog entry is needed, err on the side of adding one. |
b1258d2
to
5120ba0
Compare
5120ba0
to
926e3a9
Compare
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.
👍
It occurred to me that the PIR equivalent of isVarEventuallyEvaluated
will be useful for another optimization: if a non-strict var is eventually evaluated, then we can turn it into a strict var.
Added test coverage before changing this functionality for #1492