-
Notifications
You must be signed in to change notification settings - Fork 483
[UPLC] [Optimization] Add force-ifThenElse-delay #7042
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
[UPLC] [Optimization] Add force-ifThenElse-delay #7042
Conversation
/benchmark nofib |
1 similar comment
/benchmark nofib |
/benchmark lists |
1 similar comment
/benchmark lists |
Click here to check the status of your benchmark. |
Comparing benchmark results of 'nofib' on '24dcdb4d21' (base) and '587a9e6523' (PR) Results table
|
Click here to check the status of your benchmark. |
587a9e6
to
e9ae45c
Compare
e9ae45c
to
114b4bd
Compare
Comparing benchmark results of 'nofib' on '24dcdb4d21' (base) and '587a9e6523' (PR) Results table
|
Click here to check the status of your benchmark. |
Comparing benchmark results of 'lists' on '24dcdb4d21' (base) and '114b4bdd0d' (PR) Results table
|
Click here to check the status of your benchmark. |
Comparing benchmark results of 'lists' on '24dcdb4d21' (base) and '114b4bdd0d' (PR) Results table
|
114b4bd
to
c11221f
Compare
Force _ (Delay _ t) -> t | ||
-- Remove @Delay@s from @ifThenElse@ branches if the latter is @Force@d and the delayed term are | ||
-- pure and work-free anyway. |
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.
Should try the same for chooseList
/chooseData
/caseList
/caseData
, but let's start with the obvious thing and do it only for ifThenElse
for now.
(force ifThenElse | ||
(equalsInteger 0 index) | ||
(delay | ||
(constr 0 [(unBData (force headList args))])) | ||
(delay | ||
(force | ||
(force ifThenElse | ||
(equalsInteger 1 index) | ||
(delay | ||
(constr 1 | ||
[ (unBData | ||
(force headList args)) ])) | ||
(delay (traceError "PT1"))))))) |
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.
Man casing on Data
is gonna be a big deal.
(force ifThenElse | ||
(lessThanInteger 0 x) | ||
(delay (constr 1 [])) | ||
(delay (constr 0 [])))) |
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.
Wait, how is this not optimized?
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.
Addressed by 68a00d1.
1890 No newline at end of file | ||
1782 |
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.
-5.7% size.
3371 No newline at end of file | ||
3149 |
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.
-6.6% size.
({cpu: 6062960 | ||
| mem: 30520}) No newline at end of file | ||
({cpu: 5742960 | ||
| mem: 28520}) |
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.
-5.3% CPU and -6.6% MEM.
({cpu: 941965986 | ||
| mem: 4508802}) No newline at end of file | ||
({cpu: 909933986 | ||
| mem: 4308602}) |
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.
-3.4% CPU and -4.4% MEM.
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.
Nice, I'm surprised no one thought of doing this earlier.
Is there any part of Note [Cancelling interleaved Force-Delay pairs] that needs to be updated?
68a00d1
to
9e53d84
Compare
Done. |
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.
Sorry for reviewing this late! I think it's fine if the ifThenElse
is fully applied. @ramsay-t we'll have to modify the certifier as well, I created an issue for you: https://github.com/IntersectMBO/plutus-private/issues/1545.
This implements force-delay cancellation when delays appear under
ifThenElse
.Serves the same purpose as #7040, but does it better.