Skip to content

Print optimization report in uplc optimize#7765

Merged
zliu41 merged 3 commits into
masterfrom
zliu41/opt-report
May 6, 2026
Merged

Print optimization report in uplc optimize#7765
zliu41 merged 3 commits into
masterfrom
zliu41/opt-report

Conversation

@zliu41
Copy link
Copy Markdown
Member

@zliu41 zliu41 commented May 4, 2026

Previously, optimization numbers are only recorded in the certifier report. This makes uplc optimize generate a standalone optimization report, regardless of whether --certify is enabled.

Example report:

=== UPLC optimization report ===
Pass                     size    ΔSize             CPU            ΔCPU             Mem            ΔMem
------------------------------------------------------------------------------------------------------
<initial>                3565             288404181782                      1752469055                
FloatDelay               3573       +8    288404181782               0      1752469055               0
ForceCaseDelay           3504      -69    283210581782     -5193600000      1720009055       -32460000
LetFloatOut              3504        0    283210581782               0      1720009055               0
ForceDelay               3286     -218    275999157782     -7211424000      1674937655       -45071400
CaseOfCase               3280       -6    275603093782      -396064000      1672462255        -2475400
CaseReduce               3280        0    275603093782               0      1672462255               0
Inline                   3117     -163    264858581782    -10744512000      1605309055       -67153200
FloatDelay               3170      +53    264858581782               0      1605309055               0
ForceCaseDelay           3170        0    264858581782               0      1605309055               0
LetFloatOut              3170        0    264858581782               0      1605309055               0
ForceDelay               2910     -260    254090741782    -10767840000      1538010055       -67299000
CaseOfCase               2910        0    254090741782               0      1538010055               0
CaseReduce               2910        0    254090741782               0      1538010055               0
Inline                   2474     -436    218067557782    -36023184000      1312865155      -225144900
FloatDelay               2554      +80    218067557782               0      1312865155               0
ForceCaseDelay           2527      -27    217316549782      -751008000      1308171355        -4693800
LetFloatOut              2527        0    217316549782               0      1308171355               0
ForceDelay               2357     -170    204103557782    -13212992000      1225590155       -82581200
CaseOfCase               2357        0    204103557782               0      1225590155               0
CaseReduce               2357        0    204103557782               0      1225590155               0
Inline                   2391      +34    173477157782    -30626400000      1034175155      -191415000
FloatDelay               2402      +11    173477157782               0      1034175155               0
ForceCaseDelay           2402        0    173477157782               0      1034175155               0
LetFloatOut              2402        0    173477157782               0      1034175155               0
ForceDelay               2266     -136    161169253782    -12307904000       957250755       -76924400
CaseOfCase               2266        0    161169253782               0       957250755               0
CaseReduce               2266        0    161169253782               0       957250755               0
Inline                   1948     -318    125934997782    -35234256000       737036655      -220214100
FloatDelay               1948        0    125934997782               0       737036655               0
ForceCaseDelay           1846     -102    118993781782     -6941216000       693654055       -43382600
LetFloatOut              1846        0    118993781782               0       693654055               0
ForceDelay               1820      -26    118337877782      -655904000       689554655        -4099400
CaseOfCase               1820        0    118337877782               0       689554655               0
CaseReduce               1820        0    118337877782               0       689554655               0
Inline                   1770      -50    117353973782      -983904000       683405255        -6149400
FloatDelay               1770        0    117353973782               0       683405255               0
ForceCaseDelay           1767       -3    117353973782               0       683405255               0
LetFloatOut              1767        0    117353973782               0       683405255               0
ForceDelay               1767        0    117353973782               0       683405255               0
CaseOfCase               1767        0    117353973782               0       683405255               0
CaseReduce               1767        0    117353973782               0       683405255               0
Inline                   1764       -3    117353973782               0       683405255               0
FloatDelay               1764        0    117353973782               0       683405255               0
ForceCaseDelay           1764        0    117353973782               0       683405255               0
LetFloatOut              1764        0    117353973782               0       683405255               0
ForceDelay               1764        0    117353973782               0       683405255               0
CaseOfCase               1764        0    117353973782               0       683405255               0
CaseReduce               1764        0    117353973782               0       683405255               0
Inline                   1764        0    117353973782               0       683405255               0
FloatDelay               1764        0    117353973782               0       683405255               0
ForceCaseDelay           1764        0    117353973782               0       683405255               0
LetFloatOut              1764        0    117353973782               0       683405255               0
ForceDelay               1764        0    117353973782               0       683405255               0
CaseOfCase               1764        0    117353973782               0       683405255               0
CaseReduce               1764        0    117353973782               0       683405255               0
Inline                   1764        0    117353973782               0       683405255               0
FloatDelay               1764        0    117353973782               0       683405255               0
ForceCaseDelay           1764        0    117353973782               0       683405255               0
LetFloatOut              1764        0    117353973782               0       683405255               0
ForceDelay               1764        0    117353973782               0       683405255               0
CaseOfCase               1764        0    117353973782               0       683405255               0
CaseReduce               1764        0    117353973782               0       683405255               0
Inline                   1764        0    117353973782               0       683405255               0
FloatDelay               1764        0    117353973782               0       683405255               0
ForceCaseDelay           1764        0    117353973782               0       683405255               0
LetFloatOut              1764        0    117353973782               0       683405255               0
ForceDelay               1764        0    117353973782               0       683405255               0
CaseOfCase               1764        0    117353973782               0       683405255               0
CaseReduce               1764        0    117353973782               0       683405255               0
Inline                   1764        0    117353973782               0       683405255               0
FloatDelay               1764        0    117353973782               0       683405255               0
ForceCaseDelay           1764        0    117353973782               0       683405255               0
LetFloatOut              1764        0    117353973782               0       683405255               0
ForceDelay               1764        0    117353973782               0       683405255               0
CaseOfCase               1764        0    117353973782               0       683405255               0
CaseReduce               1764        0    117353973782               0       683405255               0
Inline                   1764        0    117353973782               0       683405255               0
FloatDelay               1764        0    117353973782               0       683405255               0
ForceCaseDelay           1764        0    117353973782               0       683405255               0
LetFloatOut              1764        0    117353973782               0       683405255               0
ForceDelay               1764        0    117353973782               0       683405255               0
CaseOfCase               1764        0    117353973782               0       683405255               0
CaseReduce               1764        0    117353973782               0       683405255               0
Inline                   1764        0    117353973782               0       683405255               0
CSE                      1773       +9    117353877782          -96000       683404655            -600
FloatDelay               1773        0    117353877782               0       683404655               0
ForceCaseDelay           1773        0    117353877782               0       683404655               0
LetFloatOut              1773        0    117353877782               0       683404655               0
ForceDelay               1773        0    117353877782               0       683404655               0
CaseOfCase               1773        0    117353877782               0       683404655               0
CaseReduce               1773        0    117353877782               0       683404655               0
Inline                   1774       +1    117353829782          -48000       683404355            -300
CSE                      1774        0    117353829782               0       683404355               0
FloatDelay               1774        0    117353829782               0       683404355               0
ForceCaseDelay           1774        0    117353829782               0       683404355               0
LetFloatOut              1774        0    117353829782               0       683404355               0
ForceDelay               1770       -4    117353829782               0       683404355               0
CaseOfCase               1770        0    117353829782               0       683404355               0
CaseReduce               1770        0    117353829782               0       683404355               0
Inline                   1756      -14    117353781782          -48000       683404055            -300
CSE                      1756        0    117353781782               0       683404055               0
FloatDelay               1756        0    117353781782               0       683404055               0
ForceCaseDelay           1756        0    117353781782               0       683404055               0
LetFloatOut              1756        0    117353781782               0       683404055               0
ForceDelay               1756        0    117353781782               0       683404055               0
CaseOfCase               1756        0    117353781782               0       683404055               0
CaseReduce               1756        0    117353781782               0       683404055               0
Inline                   1756        0    117353781782               0       683404055               0
CSE                      1756        0    117353781782               0       683404055               0
FloatDelay               1756        0    117353781782               0       683404055               0
ForceCaseDelay           1756        0    117353781782               0       683404055               0
LetFloatOut              1756        0    117353781782               0       683404055               0
ForceDelay               1756        0    117353781782               0       683404055               0
CaseOfCase               1756        0    117353781782               0       683404055               0
CaseReduce               1756        0    117353781782               0       683404055               0
Inline                   1756        0    117353781782               0       683404055               0
ApplyToCase              1738      -18    115517029782     -1836752000       671924355       -11479700

@zliu41 zliu41 requested review from a team, ana-pantilie and basetunnel May 4, 2026 18:04
@zliu41 zliu41 added the No Changelog Required Add this to skip the Changelog Check label May 4, 2026
@zliu41 zliu41 temporarily deployed to github-pages May 4, 2026 18:04 — with GitHub Actions Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

PR Preview Action v1.6.3

🚀 View preview at
https://IntersectMBO.github.io/plutus/pr-preview/docs/pr-7765/

Built to branch gh-pages at 2026-05-06 02:35 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@ana-pantilie
Copy link
Copy Markdown
Contributor

Is there any value in recording passes which did not make any changes?

I was also thinking of removing these from the trace produced for the certifier since, at least from the certifier's perspective, there's nothing interesting about proving syntactic equality which is trivial and it would be better if the trace would emphasize the passes which made actual changes.

@zliu41
Copy link
Copy Markdown
Member Author

zliu41 commented May 5, 2026

Is there any value in recording passes which did not make any changes?

It's important to tell people which passes were run, especially since there are flags to turn on/off various passes. Otherwise users would be wondering: I turned on this pass, why didn't it show up in the report?

Copy link
Copy Markdown
Contributor

@ana-pantilie ana-pantilie left a comment

Choose a reason for hiding this comment

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

We have a golden test for the certifier report version, I think we should have one for this version as well.

Also, what purpose does the certifier report have now that we have this feature? If it's just to see which optimization stages are certified and whether they passed the certifier, I'd rather we add that information to this report instead.


type OptimizerReport = [ReportEntry]

-- FIXME: we need a lot of `reverse` here because `OptimizerTrace` contains the passes
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah this is annoying, we should probably make allASTs and getOptimizerTrace (and other functions which extract elements/the list from the trace) run reverse.

Comment thread plutus-ledger-api/executables/src/PlutusCore/Executable/OptimizerReport.hs Outdated
@zliu41
Copy link
Copy Markdown
Member Author

zliu41 commented May 6, 2026

We have a golden test for the certifier report version, I think we should have one for this version as well.

Done

If it's just to see which optimization stages are certified and whether they passed the certifier, I'd rather we add that information to this report instead.

Certifier report also shows the number of optimization sites. We can merge the two reports later. It's not trivial because the certifier report is constructed in Agda. We do need this new report for the time being - it makes little sense to produce a report only when running the certifier.

@zliu41 zliu41 temporarily deployed to github-pages May 6, 2026 02:16 — with GitHub Actions Inactive
@zliu41 zliu41 merged commit 0124ee0 into master May 6, 2026
8 of 12 checks passed
@zliu41 zliu41 deleted the zliu41/opt-report branch May 6, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No Changelog Required Add this to skip the Changelog Check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants