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 immediate unlifting #4879

Merged
merged 7 commits into from
Nov 4, 2022
Merged

Conversation

michaelpj
Copy link
Contributor

Since checking shows it is in fact unused pre-Vasil.

Copy link
Contributor

@effectfully effectfully left a comment

Choose a reason for hiding this comment

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

I wanted to do it myselfffff!

Anyways, thanks.

But we need to keep the separate file for machine parameters, see my arguments below.

@michaelpj
Copy link
Contributor Author

I selfishly stole the joy of deleting code, sorry 😅

Copy link
Contributor

@effectfully effectfully left a comment

Choose a reason for hiding this comment

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

Also, is the benchmarking machine fine? I'd like to see how this change affects evaluation times (hopefully, we get a tiny speedup).

@michaelpj
Copy link
Contributor Author

No, the benchmarking machine is totally busted still.

@kwxm
Copy link
Contributor

kwxm commented Oct 3, 2022

/benchmark plutus-benchmark:validation

1 similar comment
@kwxm
Copy link
Contributor

kwxm commented Oct 3, 2022

/benchmark plutus-benchmark:validation

@kwxm
Copy link
Contributor

kwxm commented Oct 3, 2022

I cancelled the benchmarking jobs. I can log in and run things manually, but I think buidkite-agent needs to be restarted on the benchmarking machine and I have no idea how to do that (I found some binaries in the nix store but buildkite-agent start wants extra arguments and I don't know what they should be).

@kwxm
Copy link
Contributor

kwxm commented Oct 3, 2022

[Spurious benchmark results deleted]

@effectfully
Copy link
Contributor

That doesn't look good...

@kwxm
Copy link
Contributor

kwxm commented Oct 3, 2022

That doesn't look good...

In fact it looks wrong. I ran the benchmarks again on both branches and got a 2-3% speedup. I'll do it once more just to check.

@zliu41
Copy link
Member

zliu41 commented Oct 3, 2022

To run the benchmarks manually you may want to make sure to follow the steps in the script, especially the cabal clean.

Copy link
Contributor

@effectfully effectfully left a comment

Choose a reason for hiding this comment

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

I looked at the generated Core and apparently it's now worse. None of the asConstant/fromConstant business gets inlined due to toBuitinMeaning getting specialized but not inlined. Despite all the pragmas and calls to inline being in the right places. Checked three times.

@michaelpj it's that time of year where I remind how I suggested not to create long inlining chains (do feel free to remind me why we're here in the first place).

@effectfully
Copy link
Contributor

Just checked, on the recent master in DeferredMachineParameters everything's inlined properly and there's not a single call to asConstant or fromConstant.

BTW, you lost

-- GHC worker-wrapper-transforms the denotation of a builtin without this flag, which only
-- introduces a redundant indirection. There doesn't seem to be any performance difference, but the
-- Core is tidier when the worker-wrapper optimization does not happen.
{-# OPTIONS_GHC -fno-worker-wrapper #-}

in the process.

Copy link
Contributor

@effectfully effectfully left a comment

Choose a reason for hiding this comment

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

On the bright side, simply keeping DeferredMachineParameters allows us to preserve inlining. I'm not making this shit up, I swear.

So let's do that unless you feel like trying to figure out why the hell inlining only works properly there (it can be anything like DeferredMachineParameters doesn't export DefaultMachineParameters or the REWRITE rule unlike Default).

@kwxm
Copy link
Contributor

kwxm commented Oct 3, 2022

I've now manually run the benchmarks on both the master branch and this branch three times on the benchmarking machine. It looks as if I got something wrong the first time. Here are the figures for the third attempt, which are much more encouraging; the figures for the second one are very similar to these.

Script                              Old            New         Change
----------------------------------------------------------------------------------
auction_1-1                       209.4 μs	 203.9 μs      -2.6%
auction_1-2                       829.3 μs	 806.0 μs      -2.8%
auction_1-3                       820.0 μs	 796.3 μs      -2.9%
auction_1-4                       268.8 μs	 261.9 μs      -2.6%
auction_2-1                       210.4 μs	 205.1 μs      -2.5%
auction_2-2                       828.3 μs	 808.3 μs      -2.4%
auction_2-3                       1.052 ms	 1.025 ms      -2.6%
auction_2-4                       817.4 μs	 797.6 μs      -2.4%
auction_2-5                       268.7 μs	 262.7 μs      -2.2%
crowdfunding-success-1            244.0 μs	 238.7 μs      -2.2%
crowdfunding-success-2            244.2 μs	 239.1 μs      -2.1%
crowdfunding-success-3            244.6 μs	 238.5 μs      -2.5%
currency-1                        306.2 μs	 299.3 μs      -2.3%
escrow-redeem_1-1                 439.1 μs	 426.5 μs      -2.9%
escrow-redeem_1-2                 438.6 μs	 425.9 μs      -2.9%
escrow-redeem_2-1                 516.2 μs	 500.6 μs      -3.0%
escrow-redeem_2-2                 514.7 μs	 499.9 μs      -2.9%
escrow-redeem_2-3                 517.8 μs	 499.8 μs      -3.5%
escrow-refund-1                   185.0 μs	 181.3 μs      -2.0%
future-increase-margin-1          307.4 μs	 300.1 μs      -2.4%
future-increase-margin-2          694.5 μs	 675.1 μs      -2.8%
future-increase-margin-3          694.0 μs	 673.8 μs      -2.9%
future-increase-margin-4          649.3 μs	 633.5 μs      -2.4%
future-increase-margin-5          1.028 ms	 1.008 ms      -1.9%
future-pay-out-1                  306.4 μs	 298.7 μs      -2.5%
future-pay-out-2                  693.3 μs	 673.6 μs      -2.8%
future-pay-out-3                  691.9 μs	 673.7 μs      -2.6%
future-pay-out-4                  1.024 ms	 1.007 ms      -1.7%
future-settle-early-1             305.5 μs	 300.6 μs      -1.6%
future-settle-early-2             691.4 μs	 676.3 μs      -2.2%
future-settle-early-3             693.0 μs	 676.2 μs      -2.4%
future-settle-early-4             788.4 μs	 773.4 μs      -1.9%
game-sm-success_1-1               495.0 μs	 486.4 μs      -1.7%
game-sm-success_1-2               227.6 μs	 222.6 μs      -2.2%
game-sm-success_1-3               816.5 μs	 800.8 μs      -1.9%
game-sm-success_1-4               265.2 μs	 260.2 μs      -1.9%
game-sm-success_2-1               496.4 μs	 484.6 μs      -2.4%
game-sm-success_2-2               228.2 μs	 222.8 μs      -2.4%
game-sm-success_2-3               821.8 μs	 799.9 μs      -2.7%
game-sm-success_2-4               266.0 μs	 260.2 μs      -2.2%
game-sm-success_2-5               819.0 μs	 801.9 μs      -2.1%
game-sm-success_2-6               265.3 μs	 260.3 μs      -1.9%
multisig-sm-1                     513.6 μs	 501.4 μs      -2.4%
multisig-sm-2                     500.0 μs	 488.9 μs      -2.2%
multisig-sm-3                     506.8 μs	 496.4 μs      -2.1%
multisig-sm-4                     512.5 μs	 502.6 μs      -1.9%
multisig-sm-5                     726.9 μs	 716.3 μs      -1.5%
multisig-sm-6                     511.3 μs	 503.9 μs      -1.4%
multisig-sm-7                     499.1 μs	 491.1 μs      -1.6%
multisig-sm-8                     504.5 μs	 496.0 μs      -1.7%
multisig-sm-9                     510.7 μs	 501.9 μs      -1.7%
multisig-sm-10                    724.2 μs	 714.5 μs      -1.3%
ping-pong-1                       415.5 μs	 408.3 μs      -1.7%
ping-pong-2                       415.4 μs	 407.4 μs      -1.9%
ping-pong_2-1                     244.7 μs	 240.0 μs      -1.9%
prism-1                           191.1 μs	 185.4 μs      -3.0%
prism-2                           534.6 μs	 525.1 μs      -1.8%
prism-3                           454.6 μs	 443.5 μs      -2.4%
pubkey-1                          161.9 μs	 158.6 μs      -2.0%
stablecoin_1-1                    1.129 ms	 1.108 ms      -1.9%
stablecoin_1-2                    221.7 μs	 219.6 μs      -0.9%
stablecoin_1-3                    1.284 ms	 1.253 ms      -2.4%
stablecoin_1-4                    236.1 μs	 231.4 μs      -2.0%
stablecoin_1-5                    1.602 ms	 1.552 ms      -3.1%
stablecoin_1-6                    292.7 μs	 288.1 μs      -1.6%
stablecoin_2-1                    1.133 ms	 1.114 ms      -1.7%
stablecoin_2-2                    222.2 μs	 219.8 μs      -1.1%
stablecoin_2-3                    1.284 ms	 1.259 ms      -1.9%
stablecoin_2-4                    234.9 μs	 233.1 μs      -0.8%
token-account-1                   228.8 μs	 223.7 μs      -2.2%
token-account-2                   408.2 μs	 394.4 μs      -3.4%
uniswap-1                         518.6 μs	 505.3 μs      -2.6%
uniswap-2                         269.7 μs	 263.3 μs      -2.4%
uniswap-3                         2.032 ms	 1.967 ms      -3.2%
uniswap-4                         393.5 μs	 385.8 μs      -2.0%
uniswap-5                         1.401 ms	 1.358 ms      -3.1%
uniswap-6                         378.3 μs	 370.8 μs      -2.0%
vesting-1                         438.8 μs	 430.3 μs      -1.9%

I'm not sure what happened the first time. The results end like this

token-account-1                   209.9 μs	 225.0 μs      +7.2%
token-account-2                   375.6 μs	 395.4 μs      +5.3%
uniswap-1                         487.0 μs	 506.7 μs      +4.0%
uniswap-2                         244.9 μs	 263.6 μs      +7.6%
uniswap-3                         1.909 ms	 1.968 ms      +3.1%
uniswap-4                         343.2 μs	 385.2 μs     +12.2%
uniswap-5                         1.304 ms	 1.355 ms      +3.9%
uniswap-6                         331.3 μs	 370.5 μs     +11.8%
vesting-1                         411.0 μs	 428.6 μs      +4.3%

The figures for this branch are pretty similar to those above, but those for the main branch are much faster. Maybe I just failed to clean up properly, as suggested by @zliu41 .

@effectfully
Copy link
Contributor

I propose not to merge the PR until we have benchmarking results with the DeferredMachineParameters kept and used, because I've verified it multiple times that the GHC Core in the Default module is vastly superior to the one in DeferredMachineParameters. It's weird to me that we get a speedup with the current alignment.

@thealmarty
Copy link
Contributor

@michaelpj could you resolve the merge conflicts and so I can run the benchmark more properly? Or if you would prefer for me to do it let me know. Thanks!

@@ -2,6 +2,10 @@
-- We keep them separate, because the function unfolds into multiple thousands of lines of Core and
-- we want to instantiate it in two different ways on top of that, which gives another ton of Core
-- that we need to inspect, hence we dedicate an entire folder to that.

-- Core is tidier when the worker-wrapper optimization does not happen.
{-# OPTIONS_GHC -fno-worker-wrapper #-}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We shouldn't merge this, though. It's a good optimization.

@michaelpj michaelpj force-pushed the mpj/remove-immediate-unlifting branch from 942edd2 to 65fc33b Compare October 31, 2022 17:37
@michaelpj
Copy link
Contributor Author

Done

@thealmarty
Copy link
Contributor

@kwxm would you kindly benchmark this again just to double check what happens with the option turned on. Thanks.

@kwxm
Copy link
Contributor

kwxm commented Nov 1, 2022

@kwxm would you kindly benchmark this again just to double check what happens with the option turned on. Thanks.

I can't! The new nix stuff doesn't work on the benchmarking machine (wrong nix version and I seem to be unable to update it), and the old version's gone now.

@kwxm
Copy link
Contributor

kwxm commented Nov 1, 2022

Since I couldn't use the benchmarking machine I ran the benchmarks on desktop machine that I have that seems to be quite consistent (although it takes about twice as long as the usual machine). I benchmarked this branch and the current version of master twice each and couldn't see any significant difference.

Script Old New Change
auction_1-1 408.2 μs 408.6 μs +0.1%
auction_1-2 1.491 ms 1.502 ms +0.7%
auction_1-3 1.494 ms 1.489 ms -0.3%
auction_1-4 531.4 μs 530.8 μs -0.1%
auction_2-1 411.0 μs 412.5 μs +0.4%
auction_2-2 1.493 ms 1.489 ms -0.3%
auction_2-3 1.978 ms 1.970 ms -0.4%
auction_2-4 1.502 ms 1.489 ms -0.9%
auction_2-5 531.5 μs 530.5 μs -0.2%
crowdfunding-success-1 474.1 μs 475.8 μs +0.4%
crowdfunding-success-2 474.2 μs 475.7 μs +0.3%
crowdfunding-success-3 474.2 μs 475.9 μs +0.4%
currency-1 589.3 μs 589.0 μs -0.1%
escrow-redeem_1-1 808.9 μs 810.1 μs +0.1%
escrow-redeem_1-2 814.2 μs 805.8 μs -1.0%
escrow-redeem_2-1 949.7 μs 950.9 μs +0.1%
escrow-redeem_2-2 950.9 μs 950.3 μs -0.1%
escrow-redeem_2-3 951.2 μs 949.3 μs -0.2%
escrow-refund-1 348.6 μs 348.4 μs -0.1%
future-increase-margin-1 587.6 μs 587.6 μs 0.0%
future-increase-margin-2 1.272 ms 1.271 ms -0.1%
future-increase-margin-3 1.272 ms 1.270 ms -0.2%
future-increase-margin-4 1.124 ms 1.123 ms -0.1%
future-increase-margin-5 1.921 ms 1.914 ms -0.4%
future-pay-out-1 587.4 μs 590.2 μs +0.5%
future-pay-out-2 1.271 ms 1.272 ms +0.1%
future-pay-out-3 1.273 ms 1.270 ms -0.2%
future-pay-out-4 1.912 ms 1.914 ms +0.1%
future-settle-early-1 588.6 μs 589.3 μs +0.1%
future-settle-early-2 1.272 ms 1.274 ms +0.2%
future-settle-early-3 1.269 ms 1.277 ms +0.6%
future-settle-early-4 1.419 ms 1.421 ms +0.1%
game-sm-success_1-1 874.2 μs 872.6 μs -0.2%
game-sm-success_1-2 457.3 μs 467.0 μs +2.1%
game-sm-success_1-3 1.489 ms 1.482 ms -0.5%
game-sm-success_1-4 536.7 μs 534.7 μs -0.4%
game-sm-success_2-1 874.1 μs 874.4 μs +0.0%
game-sm-success_2-2 457.2 μs 458.2 μs +0.2%
game-sm-success_2-3 1.489 ms 1.485 ms -0.3%
game-sm-success_2-4 537.0 μs 536.9 μs -0.0%
game-sm-success_2-5 1.487 ms 1.489 ms +0.1%
game-sm-success_2-6 536.4 μs 534.9 μs -0.3%
multisig-sm-1 896.6 μs 896.9 μs +0.0%
multisig-sm-2 897.8 μs 867.8 μs -3.3%
multisig-sm-3 880.2 μs 880.1 μs -0.0%
multisig-sm-4 888.2 μs 885.4 μs -0.3%
multisig-sm-5 1.292 ms 1.280 ms -0.9%
multisig-sm-6 895.2 μs 895.6 μs +0.0%
multisig-sm-7 867.8 μs 867.8 μs 0.0%
multisig-sm-8 880.3 μs 880.1 μs -0.0%
multisig-sm-9 886.7 μs 887.1 μs +0.0%
multisig-sm-10 1.285 ms 1.284 ms -0.1%
ping-pong-1 752.1 μs 751.3 μs -0.1%
ping-pong-2 750.8 μs 751.9 μs +0.1%
ping-pong_2-1 452.2 μs 451.4 μs -0.2%
prism-1 385.7 μs 383.8 μs -0.5%
prism-2 939.7 μs 939.3 μs -0.0%
prism-3 860.8 μs 859.9 μs -0.1%
pubkey-1 324.1 μs 323.8 μs -0.1%
stablecoin_1-1 2.090 ms 2.091 ms +0.0%
stablecoin_1-2 446.3 μs 449.5 μs +0.7%
stablecoin_1-3 2.452 ms 2.427 ms -1.0%
stablecoin_1-4 473.5 μs 477.9 μs +0.9%
stablecoin_1-5 3.176 ms 3.160 ms -0.5%
stablecoin_1-6 584.9 μs 589.2 μs +0.7%
stablecoin_2-1 2.102 ms 2.085 ms -0.8%
stablecoin_2-2 448.6 μs 448.0 μs -0.1%
stablecoin_2-3 2.423 ms 2.437 ms +0.6%
stablecoin_2-4 472.3 μs 479.7 μs +1.6%
token-account-1 436.0 μs 435.3 μs -0.2%
token-account-2 799.6 μs 797.6 μs -0.3%
uniswap-1 1.012 ms 1.013 ms +0.1%
uniswap-2 514.1 μs 515.0 μs +0.2%
uniswap-3 4.252 ms 4.236 ms -0.4%
uniswap-4 773.3 μs 779.2 μs +0.8%
uniswap-5 2.743 ms 2.736 ms -0.3%
uniswap-6 744.3 μs 744.3 μs 0.0%
vesting-1 803.9 μs 800.2 μs -0.5%

@effectfully
Copy link
Contributor

There's that:

I looked at the generated Core and apparently it's now worse. None of the asConstant/fromConstant business gets inlined due to toBuitinMeaning getting specialized but not inlined. Despite all the pragmas and calls to inline being in the right places. Checked three times.

On the bright side, simply keeping DeferredMachineParameters allows us to preserve inlining. I'm not making this shit up, I swear.

I'd recheck, but neither nix-shell nor nix develop works on this branch for me. @thealmarty Could you generate the GHC Core for PlutusCore.Evaluation.Machine.MachineParameters.Default and either DM it to me or post it in a comment here (under a spoiler, 'cause the Core is huge)?

This branch is supposed to be a bit faster than master, because it removes one indirection on the evaluation path. Maybe it's not detectable though, but I'd expect it to be detectable.

Also I'm not really sure how we're supposed to handle issues like that without the benchmarking machine working, surely we can't ask Kenneth to run the benchmarks manually each time we change something.

@thealmarty
Copy link
Contributor

Yes will do that today. I just thought I'll have a quick check on the difference between the two files first. This wrapper option and the inline are the only differences. 🤔

Yeah sorry for the trouble Kenneth. I can benchmark locally too then. Not sure what else to do really.

@thealmarty
Copy link
Contributor

Core dump for Default in master is here.

@thealmarty
Copy link
Contributor

thealmarty commented Nov 1, 2022

Here it is. It's only around 27,000 lines of code. :P

@thealmarty
Copy link
Contributor

Here: With {-# INLINE mkMachineParametersFor #-} removed it's only 13,000 line of core.

@thealmarty
Copy link
Contributor

Just in case, here, with the line type DefaultMachineParameters = MachineParameters CekMachineCosts CekValue DefaultUni DefaultFun removed.

Copy link
Contributor

@effectfully effectfully left a comment

Choose a reason for hiding this comment

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

Here: With {-# INLINE mkMachineParametersFor #-} removed it's only 13,000 line of core.

It all looks good to me, I do not see anything bad in that output. I don't know what causes your output to be different from mine, but giving that the benchmarking results are definitely on your side, I'm going to suggest that we merge this PR (without the INLINE pragma on mkMachineParametersFor, since it's no longer doing anything useful).

@thealmarty
Copy link
Contributor

This is my locally run benchmarking result without turning off worker wrapper. This is with the wrapper turned off. Verified that there's nothing weird about it. Turning off the optimization is a bit worse.

@effectfully
Copy link
Contributor

This is my locally run benchmarking result without turning off worker wrapper. This is with the wrapper turned off. Verified that there's nothing weird about it. Turning off the optimization is a bit worse.

Running bench-compare-markdown gives me this:

| Script                                   |  Old       |  New       |   Change   |
| :------                                  |  :------:  |  :------:  |  :------:  |
| clausify/formula1                        |  26.18 ms  |  25.31 ms  |    -3,8%   |
| clausify/formula2                        |  32.37 ms  |  31.60 ms  |    -3,1%   |
| clausify/formula3                        |  87.01 ms  |  86.84 ms  |    -1,1%   |
| clausify/formula4                        |  135.1 ms  |  131.9 ms  |    -3,0%   |
| clausify/formula5                        |  554.8 ms  |  559.9 ms  |    +0,9%   |
| knights/4x4                              |  84.33 ms  |  85.64 ms  |    +1,2%   |
| knights/6x6                              |  232.6 ms  |  240.8 ms  |    +3,4%   |
| knights/8x8                              |  395.0 ms  |  401.6 ms  |    +1,5%   |
| primetest/05digits                       |  51.76 ms  |  51.12 ms  |     0,0%   |
| primetest/08digits                       |  95.77 ms  |  94.37 ms  |    -1,1%   |
| primetest/10digits                       |  134.7 ms  |  134.4 ms  |     0,0%   |
| primetest/20digits                       |  276.3 ms  |  273.3 ms  |    -1,1%   |
| primetest/30digits                       |  404.2 ms  |  403.4 ms  |    -0,2%   |
| primetest/40digits                       |  537.8 ms  |  530.9 ms  |    -1,3%   |
| primetest/50digits                       |  524.4 ms  |  517.0 ms  |    -1,3%   |
| queens4x4/bt                             |  14.52 ms  |  14.27 ms  |     0,0%   |
| queens4x4/bm                             |  20.51 ms  |  20.31 ms  |     0,0%   |
| queens4x4/bjbt1                          |  18.01 ms  |  18.30 ms  |     0,0%   |
| queens4x4/bjbt2                          |  19.43 ms  |  19.03 ms  |     0,0%   |
| queens4x4/fc                             |  46.37 ms  |  46.05 ms  |     0,0%   |
| queens5x5/bt                             |  191.4 ms  |  192.1 ms  |    +0,5%   |
| queens5x5/bm                             |  239.5 ms  |  236.8 ms  |    -1,3%   |
| queens5x5/bjbt1                          |  235.7 ms  |  230.1 ms  |    -2,1%   |
| queens5x5/bjbt2                          |  246.8 ms  |  241.8 ms  |    -2,0%   |
| queens5x5/fc                             |  596.7 ms  |  587.5 ms  |    -1,5%   |

Seems kinda random. I'm fine with both including and not including the pragma.

@thealmarty
Copy link
Contributor

I'll do some more local benchmarking today before we merge this.

@thealmarty
Copy link
Contributor

I got this when I ran the benchmarking locally. Comparing master with this branch with the INLINE pragma removed. It's like what Kenneth found before. I'll do one with the pragma in.

Script master removed INLINE Change
auction_1-1 264.5 μs 268.3 μs +1.4%
auction_1-2 901.2 μs 931.4 μs +3.4%
auction_1-3 898.3 μs 923.0 μs +2.7%
auction_1-4 346.8 μs 348.3 μs +0.4%
auction_2-1 266.8 μs 269.2 μs +0.9%
auction_2-2 899.7 μs 928.8 μs +3.2%
auction_2-3 1.182 ms 1.219 ms +3.1%
auction_2-4 900.4 μs 926.2 μs +2.9%
auction_2-5 347.3 μs 349.7 μs +0.7%
crowdfunding-success-1 307.7 μs 317.4 μs +3.2%
crowdfunding-success-2 308.7 μs 315.6 μs +2.2%
crowdfunding-success-3 308.3 μs 317.1 μs +2.9%
currency-1 362.6 μs 370.4 μs +2.2%
escrow-redeem_1-1 504.6 μs 512.8 μs +1.6%
escrow-redeem_1-2 512.1 μs 512.9 μs +0.2%
escrow-redeem_2-1 587.0 μs 598.4 μs +1.9%
escrow-redeem_2-2 586.2 μs 597.1 μs +1.9%
escrow-redeem_2-3 587.3 μs 599.3 μs +2.0%
escrow-refund-1 225.9 μs 229.4 μs +1.5%
future-increase-margin-1 363.1 μs 370.4 μs +2.0%
future-increase-margin-2 777.1 μs 793.3 μs +2.1%
future-increase-margin-3 776.1 μs 792.9 μs +2.2%
future-increase-margin-4 680.4 μs 696.6 μs +2.4%
future-increase-margin-5 1.116 ms 1.141 ms +2.2%
future-pay-out-1 362.6 μs 370.1 μs +2.1%
future-pay-out-2 777.4 μs 794.6 μs +2.2%
future-pay-out-3 777.7 μs 793.2 μs +2.0%
future-pay-out-4 1.109 ms 1.136 ms +2.4%
future-settle-early-1 363.0 μs 371.3 μs +2.3%
future-settle-early-2 776.4 μs 792.9 μs +2.1%
future-settle-early-3 778.9 μs 793.7 μs +1.9%
future-settle-early-4 830.3 μs 853.2 μs +2.8%
game-sm-success_1-1 540.6 μs 554.3 μs +2.5%
game-sm-success_1-2 299.2 μs 300.8 μs +0.5%
game-sm-success_1-3 896.5 μs 920.5 μs +2.7%
game-sm-success_1-4 348.3 μs 352.1 μs +1.1%
game-sm-success_2-1 548.2 μs 552.4 μs +0.8%
game-sm-success_2-2 298.5 μs 299.9 μs +0.5%
game-sm-success_2-3 896.3 μs 920.8 μs +2.7%
game-sm-success_2-4 348.7 μs 351.9 μs +0.9%
game-sm-success_2-5 895.2 μs 919.7 μs +2.7%
game-sm-success_2-6 348.3 μs 352.4 μs +1.2%
multisig-sm-1 551.4 μs 567.2 μs +2.9%
multisig-sm-2 535.5 μs 551.0 μs +2.9%
multisig-sm-3 540.9 μs 554.3 μs +2.5%
multisig-sm-4 548.9 μs 560.0 μs +2.0%
multisig-sm-5 778.3 μs 794.5 μs +2.1%
multisig-sm-6 552.7 μs 564.5 μs +2.1%
multisig-sm-7 536.3 μs 549.1 μs +2.4%
multisig-sm-8 543.8 μs 557.5 μs +2.5%
multisig-sm-9 551.3 μs 560.6 μs +1.7%
multisig-sm-10 795.8 μs 797.6 μs +0.2%
ping-pong-1 464.0 μs 473.5 μs +2.0%
ping-pong-2 463.3 μs 475.0 μs +2.5%
ping-pong_2-1 288.1 μs 291.5 μs +1.2%
prism-1 250.8 μs 251.2 μs +0.2%
prism-2 585.1 μs 598.6 μs +2.3%
prism-3 529.6 μs 543.5 μs +2.6%
pubkey-1 211.7 μs 214.4 μs +1.3%
stablecoin_1-1 1.234 ms 1.266 ms +2.6%
stablecoin_1-2 291.0 μs 293.9 μs +1.0%
stablecoin_1-3 1.449 ms 1.476 ms +1.9%
stablecoin_1-4 308.4 μs 312.5 μs +1.3%
stablecoin_1-5 1.899 ms 1.934 ms +1.8%
stablecoin_1-6 381.5 μs 387.5 μs +1.6%
stablecoin_2-1 1.240 ms 1.265 ms +2.0%
stablecoin_2-2 291.8 μs 293.3 μs +0.5%
stablecoin_2-3 1.449 ms 1.478 ms +2.0%
stablecoin_2-4 309.2 μs 311.4 μs +0.7%
token-account-1 272.5 μs 280.6 μs +3.0%
token-account-2 489.2 μs 502.4 μs +2.7%
uniswap-1 609.3 μs 624.3 μs +2.5%
uniswap-2 325.2 μs 331.7 μs +2.0%
uniswap-3 2.557 ms 2.612 ms +2.2%
uniswap-4 502.5 μs 508.3 μs +1.2%
uniswap-5 1.680 ms 1.707 ms +1.6%
uniswap-6 481.9 μs 489.0 μs +1.5%
vesting-1 490.7 μs 506.8 μs +3.3%

@thealmarty
Copy link
Contributor

This one is comparing with the INLINE pragma in against master.

Script master with INLINE Change
auction_1-1 264.5 μs 267.4 μs +1.1%
auction_1-2 901.2 μs 921.3 μs +2.2%
auction_1-3 898.3 μs 919.0 μs +2.3%
auction_1-4 346.8 μs 349.8 μs +0.9%
auction_2-1 266.8 μs 268.9 μs +0.8%
auction_2-2 899.7 μs 921.7 μs +2.4%
auction_2-3 1.182 ms 1.208 ms +2.2%
auction_2-4 900.4 μs 922.5 μs +2.5%
auction_2-5 347.3 μs 348.2 μs +0.3%
crowdfunding-success-1 307.7 μs 314.4 μs +2.2%
crowdfunding-success-2 308.7 μs 313.1 μs +1.4%
crowdfunding-success-3 308.3 μs 313.5 μs +1.7%
currency-1 362.6 μs 369.3 μs +1.8%
escrow-redeem_1-1 504.6 μs 514.4 μs +1.9%
escrow-redeem_1-2 512.1 μs 519.7 μs +1.5%
escrow-redeem_2-1 587.0 μs 601.9 μs +2.5%
escrow-redeem_2-2 586.2 μs 597.5 μs +1.9%
escrow-redeem_2-3 587.3 μs 601.4 μs +2.4%
escrow-refund-1 225.9 μs 229.7 μs +1.7%
future-increase-margin-1 363.1 μs 371.3 μs +2.3%
future-increase-margin-2 777.1 μs 796.1 μs +2.4%
future-increase-margin-3 776.1 μs 793.4 μs +2.2%
future-increase-margin-4 680.4 μs 696.7 μs +2.4%
future-increase-margin-5 1.116 ms 1.140 ms +2.2%
future-pay-out-1 362.6 μs 370.9 μs +2.3%
future-pay-out-2 777.4 μs 794.8 μs +2.2%
future-pay-out-3 777.7 μs 794.9 μs +2.2%
future-pay-out-4 1.109 ms 1.140 ms +2.8%
future-settle-early-1 363.0 μs 370.9 μs +2.2%
future-settle-early-2 776.4 μs 796.9 μs +2.6%
future-settle-early-3 778.9 μs 793.2 μs +1.8%
future-settle-early-4 830.3 μs 854.6 μs +2.9%
game-sm-success_1-1 540.6 μs 554.8 μs +2.6%
game-sm-success_1-2 299.2 μs 301.9 μs +0.9%
game-sm-success_1-3 896.5 μs 925.6 μs +3.2%
game-sm-success_1-4 348.3 μs 353.7 μs +1.6%
game-sm-success_2-1 548.2 μs 553.4 μs +0.9%
game-sm-success_2-2 298.5 μs 301.9 μs +1.1%
game-sm-success_2-3 896.3 μs 927.2 μs +3.4%
game-sm-success_2-4 348.7 μs 352.5 μs +1.1%
game-sm-success_2-5 895.2 μs 920.6 μs +2.8%
game-sm-success_2-6 348.3 μs 353.8 μs +1.6%
multisig-sm-1 551.4 μs 566.9 μs +2.8%
multisig-sm-2 535.5 μs 551.5 μs +3.0%
multisig-sm-3 540.9 μs 556.2 μs +2.8%
multisig-sm-4 548.9 μs 564.0 μs +2.8%
multisig-sm-5 778.3 μs 797.3 μs +2.4%
multisig-sm-6 552.7 μs 568.0 μs +2.8%
multisig-sm-7 536.3 μs 550.7 μs +2.7%
multisig-sm-8 543.8 μs 558.8 μs +2.8%
multisig-sm-9 551.3 μs 562.4 μs +2.0%
multisig-sm-10 795.8 μs 799.6 μs +0.5%
ping-pong-1 464.0 μs 476.2 μs +2.6%
ping-pong-2 463.3 μs 475.6 μs +2.7%
ping-pong_2-1 288.1 μs 291.7 μs +1.2%
prism-1 250.8 μs 252.9 μs +0.8%
prism-2 585.1 μs 600.2 μs +2.6%
prism-3 529.6 μs 547.3 μs +3.3%
pubkey-1 211.7 μs 215.3 μs +1.7%
stablecoin_1-1 1.234 ms 1.264 ms +2.4%
stablecoin_1-2 291.0 μs 295.8 μs +1.6%
stablecoin_1-3 1.449 ms 1.477 ms +1.9%
stablecoin_1-4 308.4 μs 313.1 μs +1.5%
stablecoin_1-5 1.899 ms 1.930 ms +1.6%
stablecoin_1-6 381.5 μs 387.9 μs +1.7%
stablecoin_2-1 1.240 ms 1.265 ms +2.0%
stablecoin_2-2 291.8 μs 295.6 μs +1.3%
stablecoin_2-3 1.449 ms 1.479 ms +2.1%
stablecoin_2-4 309.2 μs 311.9 μs +0.9%
token-account-1 272.5 μs 278.2 μs +2.1%
token-account-2 489.2 μs 499.1 μs +2.0%
uniswap-1 609.3 μs 622.0 μs +2.1%
uniswap-2 325.2 μs 329.8 μs +1.4%
uniswap-3 2.557 ms 2.589 ms +1.3%
uniswap-4 502.5 μs 508.1 μs +1.1%
uniswap-5 1.680 ms 1.700 ms +1.2%
uniswap-6 481.9 μs 486.9 μs +1.0%
vesting-1 490.7 μs 502.7 μs +2.4%

@thealmarty
Copy link
Contributor

This is comparing between with or without INLINE:

Script without with INLINE Change
auction_1-1 268.3 μs 267.4 μs -0.3%
auction_1-2 931.4 μs 921.3 μs -1.1%
auction_1-3 923.0 μs 919.0 μs -0.4%
auction_1-4 348.3 μs 349.8 μs +0.4%
auction_2-1 269.2 μs 268.9 μs -0.1%
auction_2-2 928.8 μs 921.7 μs -0.8%
auction_2-3 1.219 ms 1.208 ms -0.9%
auction_2-4 926.2 μs 922.5 μs -0.4%
auction_2-5 349.7 μs 348.2 μs -0.4%
crowdfunding-success-1 317.4 μs 314.4 μs -0.9%
crowdfunding-success-2 315.6 μs 313.1 μs -0.8%
crowdfunding-success-3 317.1 μs 313.5 μs -1.1%
currency-1 370.4 μs 369.3 μs -0.3%
escrow-redeem_1-1 512.8 μs 514.4 μs +0.3%
escrow-redeem_1-2 512.9 μs 519.7 μs +1.3%
escrow-redeem_2-1 598.4 μs 601.9 μs +0.6%
escrow-redeem_2-2 597.1 μs 597.5 μs +0.1%
escrow-redeem_2-3 599.3 μs 601.4 μs +0.4%
escrow-refund-1 229.4 μs 229.7 μs +0.1%
future-increase-margin-1 370.4 μs 371.3 μs +0.2%
future-increase-margin-2 793.3 μs 796.1 μs +0.4%
future-increase-margin-3 792.9 μs 793.4 μs +0.1%
future-increase-margin-4 696.6 μs 696.7 μs +0.0%
future-increase-margin-5 1.141 ms 1.140 ms -0.1%
future-pay-out-1 370.1 μs 370.9 μs +0.2%
future-pay-out-2 794.6 μs 794.8 μs +0.0%
future-pay-out-3 793.2 μs 794.9 μs +0.2%
future-pay-out-4 1.136 ms 1.140 ms +0.4%
future-settle-early-1 371.3 μs 370.9 μs -0.1%
future-settle-early-2 792.9 μs 796.9 μs +0.5%
future-settle-early-3 793.7 μs 793.2 μs -0.1%
future-settle-early-4 853.2 μs 854.6 μs +0.2%
game-sm-success_1-1 554.3 μs 554.8 μs +0.1%
game-sm-success_1-2 300.8 μs 301.9 μs +0.4%
game-sm-success_1-3 920.5 μs 925.6 μs +0.6%
game-sm-success_1-4 352.1 μs 353.7 μs +0.5%
game-sm-success_2-1 552.4 μs 553.4 μs +0.2%
game-sm-success_2-2 299.9 μs 301.9 μs +0.7%
game-sm-success_2-3 920.8 μs 927.2 μs +0.7%
game-sm-success_2-4 351.9 μs 352.5 μs +0.2%
game-sm-success_2-5 919.7 μs 920.6 μs +0.1%
game-sm-success_2-6 352.4 μs 353.8 μs +0.4%
multisig-sm-1 567.2 μs 566.9 μs -0.1%
multisig-sm-2 551.0 μs 551.5 μs +0.1%
multisig-sm-3 554.3 μs 556.2 μs +0.3%
multisig-sm-4 560.0 μs 564.0 μs +0.7%
multisig-sm-5 794.5 μs 797.3 μs +0.4%
multisig-sm-6 564.5 μs 568.0 μs +0.6%
multisig-sm-7 549.1 μs 550.7 μs +0.3%
multisig-sm-8 557.5 μs 558.8 μs +0.2%
multisig-sm-9 560.6 μs 562.4 μs +0.3%
multisig-sm-10 797.6 μs 799.6 μs +0.3%
ping-pong-1 473.5 μs 476.2 μs +0.6%
ping-pong-2 475.0 μs 475.6 μs +0.1%
ping-pong_2-1 291.5 μs 291.7 μs +0.1%
prism-1 251.2 μs 252.9 μs +0.7%
prism-2 598.6 μs 600.2 μs +0.3%
prism-3 543.5 μs 547.3 μs +0.7%
pubkey-1 214.4 μs 215.3 μs +0.4%
stablecoin_1-1 1.266 ms 1.264 ms -0.2%
stablecoin_1-2 293.9 μs 295.8 μs +0.6%
stablecoin_1-3 1.476 ms 1.477 ms +0.1%
stablecoin_1-4 312.5 μs 313.1 μs +0.2%
stablecoin_1-5 1.934 ms 1.930 ms -0.2%
stablecoin_1-6 387.5 μs 387.9 μs +0.1%
stablecoin_2-1 1.265 ms 1.265 ms 0.0%
stablecoin_2-2 293.3 μs 295.6 μs +0.8%
stablecoin_2-3 1.478 ms 1.479 ms +0.1%
stablecoin_2-4 311.4 μs 311.9 μs +0.2%
token-account-1 280.6 μs 278.2 μs -0.9%
token-account-2 502.4 μs 499.1 μs -0.7%
uniswap-1 624.3 μs 622.0 μs -0.4%
uniswap-2 331.7 μs 329.8 μs -0.6%
uniswap-3 2.612 ms 2.589 ms -0.9%
uniswap-4 508.3 μs 508.1 μs -0.0%
uniswap-5 1.707 ms 1.700 ms -0.4%
uniswap-6 489.0 μs 486.9 μs -0.4%
vesting-1 506.8 μs 502.7 μs -0.8%

@thealmarty
Copy link
Contributor

So, confirmed that the INLINE pragma isn't helping. I agree we should merge without the pragma (so can merge the PR as is). I would have done more benchmarking if the machine is working....

@effectfully
Copy link
Contributor

Comparing master with this branch with the INLINE pragma removed. It's like what Kenneth found before.

So we got, in chronological order:

Not a particularly good progression! Anyway, it can be noise or just the benchmarking machine is being weird, which it can sometimes, so I personally don't care.

So, confirmed that the INLINE pragma isn't helping.

Could you leave a comment in the code? It's useful info.

@thealmarty thealmarty force-pushed the mpj/remove-immediate-unlifting branch 3 times, most recently from 5258fb0 to e0d22d7 Compare November 3, 2022 16:17
@michaelpj michaelpj force-pushed the mpj/remove-immediate-unlifting branch from e0d22d7 to 70648d1 Compare November 4, 2022 10:53
@kwxm
Copy link
Contributor

kwxm commented Nov 4, 2022

/benchmark validation

@michaelpj michaelpj merged commit d1f6751 into master Nov 4, 2022
@michaelpj michaelpj deleted the mpj/remove-immediate-unlifting branch November 4, 2022 13:12
@effectfully
Copy link
Contributor

🎉

brainrake pushed a commit to mlabs-haskell/plutus that referenced this pull request Dec 8, 2022
* Remove immediate unlifting

Since checking shows it is in fact unused pre-Vasil.

* Nits

* Remvoe BuiltinRuntimeOptions

* Remove {-# INLINE mkMachineParametersFor #-}.

* Noop commit

* again

* fix

Co-authored-by: Marty Stumpf <thealmartyblog@gmail.com>
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.

6 participants