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

PLT-1432: [Builtins] Make 'geq' inlinable #5061

Merged
merged 1 commit into from
Feb 16, 2023

Conversation

effectfully
Copy link
Contributor

@michaelpj made me learn about loop-breakers, hence this PR achieving more or less the same as #4462 and #4463 except without as much burden.

My quick-and-dirty benchmarking suggests that this does give us a speedup, plus the Core definitely looks better.

Manual benchmarking is a pain in the ass, so let's wait for automated benchmarking to arise from the ashes, hopefully that'll happen soonish. Unless of course somebody wants to volunteer.

@effectfully
Copy link
Contributor Author

/benchmark plutus-benchmark:validation

@github-actions
Copy link
Contributor

Comparing benchmark results of 'plutus-benchmark:validation' on 'd1becb405' (base) and 'd1becb405' (PR)

Results table
Script d1becb4 d1becb4 Change
auction_1-1 148.2 μs 148.4 μs +0.1%
auction_1-2 644.5 μs 653.4 μs +1.4%
auction_1-3 631.5 μs 639.8 μs +1.3%
auction_1-4 191.3 μs 192.5 μs +0.6%
auction_2-1 151.4 μs 152.0 μs +0.4%
auction_2-2 647.2 μs 651.5 μs +0.7%
auction_2-3 849.3 μs 857.6 μs +1.0%
auction_2-4 636.5 μs 637.4 μs +0.1%
auction_2-5 190.7 μs 193.4 μs +1.4%
crowdfunding-success-1 178.5 μs 180.5 μs +1.1%
crowdfunding-success-2 178.8 μs 180.1 μs +0.7%
crowdfunding-success-3 178.7 μs 180.9 μs +1.2%
currency-1 234.9 μs 236.2 μs +0.6%
escrow-redeem_1-1 328.6 μs 331.5 μs +0.9%
escrow-redeem_1-2 326.4 μs 330.2 μs +1.2%
escrow-redeem_2-1 380.0 μs 386.9 μs +1.8%
escrow-redeem_2-2 381.6 μs 384.7 μs +0.8%
escrow-redeem_2-3 380.8 μs 385.2 μs +1.2%
escrow-refund-1 132.1 μs 133.7 μs +1.2%
future-increase-margin-1 234.9 μs 237.6 μs +1.1%
future-increase-margin-2 517.2 μs 524.0 μs +1.3%
future-increase-margin-3 516.4 μs 522.1 μs +1.1%
future-increase-margin-4 480.3 μs 487.8 μs +1.6%
future-increase-margin-5 844.3 μs 858.0 μs +1.6%
future-pay-out-1 233.6 μs 236.6 μs +1.3%
future-pay-out-2 515.8 μs 524.9 μs +1.8%
future-pay-out-3 517.4 μs 522.3 μs +0.9%
future-pay-out-4 847.9 μs 851.3 μs +0.4%
future-settle-early-1 234.3 μs 236.7 μs +1.0%
future-settle-early-2 516.5 μs 522.5 μs +1.2%
future-settle-early-3 522.5 μs 521.7 μs -0.2%
future-settle-early-4 632.1 μs 641.4 μs +1.5%
game-sm-success_1-1 370.9 μs 378.3 μs +2.0%
game-sm-success_1-2 164.2 μs 165.1 μs +0.5%
game-sm-success_1-3 633.1 μs 638.6 μs +0.9%
game-sm-success_1-4 192.0 μs 193.5 μs +0.8%
game-sm-success_2-1 373.5 μs 376.9 μs +0.9%
game-sm-success_2-2 163.8 μs 165.1 μs +0.8%
game-sm-success_2-3 632.5 μs 633.2 μs +0.1%
game-sm-success_2-4 191.1 μs 191.4 μs +0.2%
game-sm-success_2-5 633.7 μs 639.4 μs +0.9%
game-sm-success_2-6 191.1 μs 191.5 μs +0.2%
multisig-sm-1 386.6 μs 388.0 μs +0.4%
multisig-sm-2 376.2 μs 379.4 μs +0.9%
multisig-sm-3 381.3 μs 383.8 μs +0.7%
multisig-sm-4 379.7 μs 380.4 μs +0.2%
multisig-sm-5 564.2 μs 565.2 μs +0.2%
multisig-sm-6 385.3 μs 388.3 μs +0.8%
multisig-sm-7 377.6 μs 378.3 μs +0.2%
multisig-sm-8 384.6 μs 384.8 μs +0.1%
multisig-sm-9 385.2 μs 381.4 μs -1.0%
multisig-sm-10 568.2 μs 564.5 μs -0.7%
ping-pong-1 322.1 μs 316.6 μs -1.7%
ping-pong-2 318.9 μs 319.8 μs +0.3%
ping-pong_2-1 182.6 μs 180.1 μs -1.4%
prism-1 139.9 μs 139.3 μs -0.4%
prism-2 399.1 μs 395.4 μs -0.9%
prism-3 338.5 μs 337.8 μs -0.2%
pubkey-1 116.9 μs 116.5 μs -0.3%
stablecoin_1-1 955.2 μs 944.7 μs -1.1%
stablecoin_1-2 162.4 μs 162.3 μs -0.1%
stablecoin_1-3 1.097 ms 1.090 ms -0.6%
stablecoin_1-4 172.5 μs 172.2 μs -0.2%
stablecoin_1-5 1.378 ms 1.376 ms -0.1%
stablecoin_1-6 214.0 μs 213.8 μs -0.1%
stablecoin_2-1 958.4 μs 951.9 μs -0.7%
stablecoin_2-2 163.1 μs 161.9 μs -0.7%
stablecoin_2-3 1.100 ms 1.082 ms -1.6%
stablecoin_2-4 172.8 μs 171.6 μs -0.7%
token-account-1 172.4 μs 171.1 μs -0.8%
token-account-2 310.1 μs 308.1 μs -0.6%
uniswap-1 409.3 μs 405.8 μs -0.9%
uniswap-2 200.6 μs 200.0 μs -0.3%
uniswap-3 1.783 ms 1.761 ms -1.2%
uniswap-4 278.6 μs 276.2 μs -0.9%
uniswap-5 1.137 ms 1.125 ms -1.1%
uniswap-6 272.5 μs 269.6 μs -1.1%
vesting-1 336.5 μs 332.3 μs -1.2%

@effectfully
Copy link
Contributor Author

^ almost all +, then almost all -

Suspicious.

@effectfully
Copy link
Contributor Author

@michaelpj you can see here that benchmarks are being run even though the CI says there's an error. The CI seems to run something different from what we do.

@zeme-iohk
Copy link

^ almost all +, then almost all -

Suspicious.

It's comparing the same branch.
I've updated the benchmarking script, added more logs.
I'll trigger the bench now

@zeme-iohk
Copy link

/benchmark plutus-benchmark:validation

@effectfully
Copy link
Contributor Author

It's comparing the same branch.

Oh, indeed, I didn't notice that!

But then it's even more suspicious! Why would the first half be consistently slower and the second one consistently faster if we're comparing the same branch? It seems like the chance of this occurring randomly is negligible.

@github-actions
Copy link
Contributor

Comparing benchmark results of 'plutus-benchmark:validation' on 'a12b99450' (base) and 'a12b99450' (PR)

Results table
Script a12b994 a12b994 Change
auction_1-1 148.5 μs 149.0 μs +0.3%
auction_1-2 641.8 μs 648.5 μs +1.0%
auction_1-3 635.9 μs 634.2 μs -0.3%
auction_1-4 192.2 μs 192.7 μs +0.3%
auction_2-1 151.7 μs 152.1 μs +0.3%
auction_2-2 643.2 μs 642.2 μs -0.2%
auction_2-3 849.6 μs 849.4 μs -0.0%
auction_2-4 637.5 μs 638.0 μs +0.1%
auction_2-5 192.0 μs 192.0 μs 0.0%
crowdfunding-success-1 178.3 μs 178.7 μs +0.2%
crowdfunding-success-2 178.4 μs 179.3 μs +0.5%
crowdfunding-success-3 178.3 μs 178.7 μs +0.2%
currency-1 232.9 μs 233.7 μs +0.3%
escrow-redeem_1-1 324.3 μs 326.4 μs +0.6%
escrow-redeem_1-2 325.2 μs 324.9 μs -0.1%
escrow-redeem_2-1 379.1 μs 381.2 μs +0.6%
escrow-redeem_2-2 379.3 μs 379.2 μs -0.0%
escrow-redeem_2-3 379.2 μs 379.8 μs +0.2%
escrow-refund-1 132.0 μs 132.1 μs +0.1%
future-increase-margin-1 234.0 μs 234.0 μs 0.0%
future-increase-margin-2 513.6 μs 513.9 μs +0.1%
future-increase-margin-3 513.5 μs 514.1 μs +0.1%
future-increase-margin-4 485.1 μs 486.0 μs +0.2%
future-increase-margin-5 852.0 μs 845.4 μs -0.8%
future-pay-out-1 232.5 μs 232.8 μs +0.1%
future-pay-out-2 513.7 μs 517.9 μs +0.8%
future-pay-out-3 515.8 μs 513.7 μs -0.4%
future-pay-out-4 851.8 μs 852.2 μs +0.0%
future-settle-early-1 232.5 μs 232.7 μs +0.1%
future-settle-early-2 513.7 μs 514.0 μs +0.1%
future-settle-early-3 514.2 μs 514.9 μs +0.1%
future-settle-early-4 637.2 μs 636.4 μs -0.1%
game-sm-success_1-1 376.5 μs 374.9 μs -0.4%
game-sm-success_1-2 164.7 μs 165.0 μs +0.2%
game-sm-success_1-3 633.8 μs 642.5 μs +1.4%
game-sm-success_1-4 192.1 μs 193.0 μs +0.5%
game-sm-success_2-1 375.8 μs 378.7 μs +0.8%
game-sm-success_2-2 164.7 μs 166.2 μs +0.9%
game-sm-success_2-3 635.4 μs 641.5 μs +1.0%
game-sm-success_2-4 192.7 μs 195.1 μs +1.2%
game-sm-success_2-5 637.8 μs 638.8 μs +0.2%
game-sm-success_2-6 191.9 μs 196.1 μs +2.2%
multisig-sm-1 389.9 μs 386.4 μs -0.9%
multisig-sm-2 380.2 μs 374.3 μs -1.6%
multisig-sm-3 383.4 μs 378.0 μs -1.4%
multisig-sm-4 383.4 μs 377.1 μs -1.6%
multisig-sm-5 563.6 μs 557.9 μs -1.0%
multisig-sm-6 388.6 μs 385.1 μs -0.9%
multisig-sm-7 380.0 μs 374.4 μs -1.5%
multisig-sm-8 382.3 μs 381.0 μs -0.3%
multisig-sm-9 386.9 μs 380.0 μs -1.8%
multisig-sm-10 563.9 μs 555.0 μs -1.6%
ping-pong-1 317.4 μs 312.5 μs -1.5%
ping-pong-2 317.1 μs 313.3 μs -1.2%
ping-pong_2-1 180.2 μs 178.7 μs -0.8%
prism-1 138.1 μs 137.7 μs -0.3%
prism-2 396.3 μs 392.4 μs -1.0%
prism-3 336.0 μs 331.8 μs -1.2%
pubkey-1 117.9 μs 117.0 μs -0.8%
stablecoin_1-1 936.7 μs 937.6 μs +0.1%
stablecoin_1-2 161.3 μs 161.7 μs +0.2%
stablecoin_1-3 1.074 ms 1.073 ms -0.1%
stablecoin_1-4 171.5 μs 171.1 μs -0.2%
stablecoin_1-5 1.352 ms 1.354 ms +0.1%
stablecoin_1-6 212.7 μs 212.0 μs -0.3%
stablecoin_2-1 936.4 μs 938.6 μs +0.2%
stablecoin_2-2 161.4 μs 161.7 μs +0.2%
stablecoin_2-3 1.074 ms 1.083 ms +0.8%
stablecoin_2-4 170.8 μs 171.7 μs +0.5%
token-account-1 169.6 μs 170.9 μs +0.8%
token-account-2 307.0 μs 307.4 μs +0.1%
uniswap-1 397.7 μs 399.4 μs +0.4%
uniswap-2 197.6 μs 198.8 μs +0.6%
uniswap-3 1.745 ms 1.748 ms +0.2%
uniswap-4 276.6 μs 276.6 μs 0.0%
uniswap-5 1.117 ms 1.120 ms +0.3%
uniswap-6 271.1 μs 271.2 μs +0.0%
vesting-1 332.0 μs 333.8 μs +0.5%

@effectfully
Copy link
Contributor Author

@zeme-iohk I think it's the same branch still.

Also we can observe a very similar pattern in the numbers: noise, then multiple consecutive +, one of which is beyond what we used to consider the noise threshold (2%):

Screenshot from 2023-01-27 14-41-15

then lots of consecutive -:

Screenshot from 2023-01-27 14-36-17

then noise again.

I believe it's extremely unlikely that this is happening by chance. I suspect there's a problem with either our benchmarks or the machine.

@effectfully effectfully force-pushed the effectfully/builtins/evaluation/inlinable-geq branch from 5cf0066 to 758965f Compare February 9, 2023 00:31
@effectfully
Copy link
Contributor Author

/benchmark plutus-benchmark:validation

@zeme-iohk
Copy link

/benchmark plutus-benchmark:validation

My latest change seems to have broken benchmarking. Sorry about this, will fix asap

@effectfully
Copy link
Contributor Author

effectfully commented Feb 9, 2023

@zeme-iohk no problem & no rush.

@zeme-iohk
Copy link

/benchmark plutus-benchmark:validation

@IntersectMBO IntersectMBO deleted a comment from github-actions bot Feb 9, 2023
@zeme-iohk
Copy link

I've fixed it manually here:

Comparing benchmark results of ' plutus-benchmark:validation' on '41bfd20d7' (base) and '758965ff6' (PR)

Results table

Script 41bfd20 758965f Change
auction_1-1 149.7 μs 146.6 μs -2.1%
auction_1-2 642.0 μs 639.0 μs -0.5%
auction_1-3 634.6 μs 631.5 μs -0.5%
auction_1-4 193.4 μs 188.9 μs -2.3%
auction_2-1 153.0 μs 149.4 μs -2.4%
auction_2-2 642.3 μs 632.5 μs -1.5%
auction_2-3 850.1 μs 828.0 μs -2.6%
auction_2-4 639.4 μs 626.4 μs -2.0%
auction_2-5 193.0 μs 188.2 μs -2.5%
crowdfunding-success-1 179.8 μs 173.5 μs -3.5%
crowdfunding-success-2 179.3 μs 173.0 μs -3.5%
crowdfunding-success-3 179.4 μs 173.1 μs -3.5%
currency-1 235.5 μs 232.0 μs -1.5%
escrow-redeem_1-1 328.4 μs 316.0 μs -3.8%
escrow-redeem_1-2 327.1 μs 316.0 μs -3.4%
escrow-redeem_2-1 381.8 μs 374.0 μs -2.0%
escrow-redeem_2-2 380.1 μs 371.3 μs -2.3%
escrow-redeem_2-3 380.1 μs 371.4 μs -2.3%
escrow-refund-1 132.9 μs 131.6 μs -1.0%
future-increase-margin-1 236.2 μs 233.3 μs -1.2%
future-increase-margin-2 519.4 μs 505.9 μs -2.6%
future-increase-margin-3 517.3 μs 506.5 μs -2.1%
future-increase-margin-4 482.7 μs 479.8 μs -0.6%
future-increase-margin-5 849.0 μs 837.0 μs -1.4%
future-pay-out-1 234.4 μs 231.8 μs -1.1%
future-pay-out-2 519.0 μs 505.6 μs -2.6%
future-pay-out-3 520.0 μs 505.6 μs -2.8%
future-pay-out-4 847.8 μs 828.1 μs -2.3%
future-settle-early-1 234.5 μs 232.8 μs -0.7%
future-settle-early-2 516.3 μs 505.5 μs -2.1%
future-settle-early-3 517.6 μs 508.2 μs -1.8%
future-settle-early-4 631.8 μs 625.1 μs -1.1%
game-sm-success_1-1 370.5 μs 368.5 μs -0.5%
game-sm-success_1-2 164.2 μs 161.8 μs -1.5%
game-sm-success_1-3 630.9 μs 628.5 μs -0.4%
game-sm-success_1-4 191.6 μs 187.8 μs -2.0%
game-sm-success_2-1 373.9 μs 369.8 μs -1.1%
game-sm-success_2-2 164.4 μs 161.9 μs -1.5%
game-sm-success_2-3 632.9 μs 627.5 μs -0.9%
game-sm-success_2-4 191.3 μs 188.0 μs -1.7%
game-sm-success_2-5 633.6 μs 631.4 μs -0.3%
game-sm-success_2-6 191.4 μs 187.6 μs -2.0%
multisig-sm-1 389.8 μs 377.5 μs -3.2%
multisig-sm-2 377.5 μs 368.7 μs -2.3%
multisig-sm-3 381.2 μs 373.2 μs -2.1%
multisig-sm-4 380.9 μs 380.4 μs -0.1%
multisig-sm-5 562.5 μs 551.2 μs -2.0%
multisig-sm-6 388.0 μs 375.7 μs -3.2%
multisig-sm-7 378.7 μs 365.5 μs -3.5%
multisig-sm-8 384.0 μs 375.5 μs -2.2%
multisig-sm-9 382.9 μs 378.5 μs -1.1%
multisig-sm-10 562.9 μs 551.0 μs -2.1%
ping-pong-1 315.7 μs 311.7 μs -1.3%
ping-pong-2 316.3 μs 311.7 μs -1.5%
ping-pong_2-1 180.0 μs 177.1 μs -1.6%
prism-1 139.3 μs 134.6 μs -3.4%
prism-2 397.2 μs 390.2 μs -1.8%
prism-3 336.1 μs 333.4 μs -0.8%
pubkey-1 117.8 μs 115.1 μs -2.3%
stablecoin_1-1 946.4 μs 934.0 μs -1.3%
stablecoin_1-2 161.6 μs 157.7 μs -2.4%
stablecoin_1-3 1.087 ms 1.064 ms -2.1%
stablecoin_1-4 172.2 μs 166.6 μs -3.3%
stablecoin_1-5 1.371 ms 1.340 ms -2.3%
stablecoin_1-6 214.3 μs 207.8 μs -3.0%
stablecoin_2-1 951.8 μs 929.7 μs -2.3%
stablecoin_2-2 162.5 μs 158.0 μs -2.8%
stablecoin_2-3 1.081 ms 1.064 ms -1.6%
stablecoin_2-4 172.6 μs 166.8 μs -3.4%
token-account-1 172.3 μs 168.1 μs -2.4%
token-account-2 308.1 μs 309.5 μs +0.5%
uniswap-1 402.1 μs 397.7 μs -1.1%
uniswap-2 200.2 μs 193.2 μs -3.5%
uniswap-3 1.745 ms 1.720 ms -1.4%
uniswap-4 281.0 μs 275.5 μs -2.0%
uniswap-5 1.123 ms 1.103 ms -1.8%
uniswap-6 275.0 μs 267.6 μs -2.7%
vesting-1 333.2 μs 328.1 μs -1.5%

@IntersectMBO IntersectMBO deleted a comment from github-actions bot Feb 9, 2023
@zeme-iohk
Copy link

/benchmark nofib

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

Click here to check the status of your benchmark.

@michaelpj
Copy link
Contributor

That's some good stuff right there.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

Comparing benchmark results of ' nofib' on 'f6963f009' (base) and '758965ff6' (PR)

Results table
Script f6963f0 758965f Change
clausify/formula1 19.34 ms 19.23 ms -0.6%
clausify/formula2 24.60 ms 24.31 ms -1.2%
clausify/formula3 67.15 ms 66.46 ms -1.0%
clausify/formula4 96.59 ms 95.40 ms -1.2%
clausify/formula5 424.2 ms 420.3 ms -0.9%
knights/4x4 55.62 ms 54.29 ms -2.4%
knights/6x6 146.0 ms 144.4 ms -1.1%
knights/8x8 239.4 ms 237.7 ms -0.7%
primetest/05digits 28.20 ms 27.40 ms -2.8%
primetest/08digits 50.75 ms 49.56 ms -2.3%
primetest/10digits 70.76 ms 69.11 ms -2.3%
primetest/20digits 146.6 ms 143.9 ms -1.8%
primetest/30digits 214.7 ms 211.1 ms -1.7%
primetest/40digits 295.9 ms 291.6 ms -1.5%
primetest/50digits 283.0 ms 278.7 ms -1.5%
queens4x4/bt 10.05 ms 9.748 ms -3.0%
queens4x4/bm 14.16 ms 13.71 ms -3.2%
queens4x4/bjbt1 12.68 ms 12.51 ms -1.3%
queens4x4/bjbt2 13.21 ms 13.07 ms -1.1%
queens4x4/fc 31.33 ms 31.07 ms -0.8%
queens5x5/bt 130.2 ms 129.5 ms -0.5%
queens5x5/bm 165.8 ms 162.1 ms -2.2%
queens5x5/bjbt1 161.5 ms 158.1 ms -2.1%
queens5x5/bjbt2 169.3 ms 165.7 ms -2.1%
queens5x5/fc 395.5 ms 391.9 ms -0.9%

@effectfully
Copy link
Contributor Author

/benchmark plutus-benchmark:validation

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

Click here to check the status of your benchmark.

@effectfully
Copy link
Contributor Author

Eek, I should've refreshed the page before running the benchmarks again. These are going to be the same. Although I can use them to check that the machine is consistent, so it's not all waste.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

Comparing benchmark results of ' plutus-benchmark:validation' on '1843a7dab' (base) and '758965ff6' (PR)

Results table
Script 1843a7d 758965f Change
auction_1-1 150.6 μs 146.6 μs -2.7%
auction_1-2 643.3 μs 630.3 μs -2.0%
auction_1-3 632.4 μs 622.7 μs -1.5%
auction_1-4 192.8 μs 188.3 μs -2.3%
auction_2-1 153.1 μs 149.5 μs -2.4%
auction_2-2 642.9 μs 633.7 μs -1.4%
auction_2-3 848.5 μs 830.5 μs -2.1%
auction_2-4 637.9 μs 626.7 μs -1.8%
auction_2-5 193.1 μs 188.5 μs -2.4%
crowdfunding-success-1 179.2 μs 172.7 μs -3.6%
crowdfunding-success-2 179.3 μs 172.8 μs -3.6%
crowdfunding-success-3 179.4 μs 173.6 μs -3.2%
currency-1 234.6 μs 232.1 μs -1.1%
escrow-redeem_1-1 326.1 μs 315.9 μs -3.1%
escrow-redeem_1-2 325.6 μs 313.7 μs -3.7%
escrow-redeem_2-1 378.5 μs 371.5 μs -1.8%
escrow-redeem_2-2 381.1 μs 370.1 μs -2.9%
escrow-redeem_2-3 380.6 μs 371.0 μs -2.5%
escrow-refund-1 132.8 μs 132.4 μs -0.3%
future-increase-margin-1 234.1 μs 234.0 μs -0.0%
future-increase-margin-2 513.4 μs 508.5 μs -1.0%
future-increase-margin-3 514.6 μs 511.2 μs -0.7%
future-increase-margin-4 475.4 μs 480.2 μs +1.0%
future-increase-margin-5 842.5 μs 841.8 μs -0.1%
future-pay-out-1 234.1 μs 233.8 μs -0.1%
future-pay-out-2 516.2 μs 511.5 μs -0.9%
future-pay-out-3 516.3 μs 507.2 μs -1.8%
future-pay-out-4 840.9 μs 838.3 μs -0.3%
future-settle-early-1 233.3 μs 233.3 μs 0.0%
future-settle-early-2 514.4 μs 506.1 μs -1.6%
future-settle-early-3 515.3 μs 508.9 μs -1.2%
future-settle-early-4 626.4 μs 625.9 μs -0.1%
game-sm-success_1-1 369.7 μs 368.4 μs -0.4%
game-sm-success_1-2 164.1 μs 162.1 μs -1.2%
game-sm-success_1-3 626.9 μs 630.2 μs +0.5%
game-sm-success_1-4 191.4 μs 188.5 μs -1.5%
game-sm-success_2-1 371.5 μs 372.4 μs +0.2%
game-sm-success_2-2 163.8 μs 162.9 μs -0.5%
game-sm-success_2-3 629.2 μs 630.9 μs +0.3%
game-sm-success_2-4 190.4 μs 188.2 μs -1.2%
game-sm-success_2-5 628.0 μs 633.8 μs +0.9%
game-sm-success_2-6 190.8 μs 188.6 μs -1.2%
multisig-sm-1 386.2 μs 379.0 μs -1.9%
multisig-sm-2 373.8 μs 368.2 μs -1.5%
multisig-sm-3 378.3 μs 375.0 μs -0.9%
multisig-sm-4 377.9 μs 382.1 μs +1.1%
multisig-sm-5 558.0 μs 554.7 μs -0.6%
multisig-sm-6 384.5 μs 378.3 μs -1.6%
multisig-sm-7 375.7 μs 367.1 μs -2.3%
multisig-sm-8 381.3 μs 375.7 μs -1.5%
multisig-sm-9 378.2 μs 382.1 μs +1.0%
multisig-sm-10 559.0 μs 552.9 μs -1.1%
ping-pong-1 314.0 μs 313.5 μs -0.2%
ping-pong-2 313.5 μs 313.6 μs +0.0%
ping-pong_2-1 180.0 μs 177.9 μs -1.2%
prism-1 139.0 μs 135.3 μs -2.7%
prism-2 394.0 μs 389.9 μs -1.0%
prism-3 334.9 μs 334.9 μs 0.0%
pubkey-1 117.2 μs 115.5 μs -1.5%
stablecoin_1-1 938.9 μs 941.8 μs +0.3%
stablecoin_1-2 161.7 μs 158.6 μs -1.9%
stablecoin_1-3 1.081 ms 1.074 ms -0.6%
stablecoin_1-4 172.1 μs 167.1 μs -2.9%
stablecoin_1-5 1.365 ms 1.347 ms -1.3%
stablecoin_1-6 212.9 μs 208.9 μs -1.9%
stablecoin_2-1 942.6 μs 941.0 μs -0.2%
stablecoin_2-2 161.8 μs 159.4 μs -1.5%
stablecoin_2-3 1.081 ms 1.077 ms -0.4%
stablecoin_2-4 171.7 μs 167.5 μs -2.4%
token-account-1 171.2 μs 168.6 μs -1.5%
token-account-2 307.9 μs 309.4 μs +0.5%
uniswap-1 399.5 μs 403.2 μs +0.9%
uniswap-2 199.0 μs 195.4 μs -1.8%
uniswap-3 1.743 ms 1.736 ms -0.4%
uniswap-4 279.4 μs 275.5 μs -1.4%
uniswap-5 1.117 ms 1.109 ms -0.7%
uniswap-6 275.2 μs 268.7 μs -2.4%
vesting-1 332.4 μs 332.4 μs 0.0%

@effectfully
Copy link
Contributor Author

Only -1.16% on average. One of those cases where the numbers appear better than what they actually are. But it's kinda free and we see multiple 3+% improvements and even more 2+% improvements and all slowdowns are <=1.1%, i.e. below the noise threshold. Plus Core looks better and it may (likely won't) unlock more optimizations in future.

Needs docs of course.

@michaelpj do you have any opinion?

@effectfully
Copy link
Contributor Author

effectfully commented Feb 9, 2023

(nofib is -1.6% on average)

BTW, the reason we're not seeing a larger speedup is GHC weirdly inlining geq for Integer regardless of whether we have these changes or not. I don't know why GHC randomly decides to only inline geq for Integer without these changes and I don't understand how that is even possible given the recursion, but making geq universally inlinable will make the code less brittle too.

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.

I think this is fine with some docs, otherwise it's a bit obscure. I'm actually unsure whether this works reliably. Are we guaranteed that GHC will pick geqRec as the loop-breaker because of the pragmas or something?

@effectfully
Copy link
Contributor Author

I think this is fine with some docs, otherwise it's a bit obscure.

Sure, I was going to write some.

I'm actually unsure whether this works reliably. Are we guaranteed that GHC will pick geqRec as the loop-breaker because of the pragmas or something?

No idea. But it can't be worse than what we have now, because what we have isn't supposed to get inlined at all (even though it somehow does occasionally and inconsistently). And the approach of this PR is the best I can think of and I did spend a lot of time investigating other possible options (see #4462 and #4463)

So I think this PR is our best bet and we should go with it even if we're not sure that GHC will continue to inline geq the way we want it. In the worst case we'll just get back to not having this 1% speedup, which isn't too horrible.

@zliu41 zliu41 changed the title [Builtins] Make 'geq' inlinable PLT-1432: [Builtins] Make 'geq' inlinable Feb 13, 2023
@effectfully effectfully force-pushed the effectfully/builtins/evaluation/inlinable-geq branch 2 times, most recently from 58f7850 to 918afb6 Compare February 15, 2023 17:36
@effectfully
Copy link
Contributor Author

/benchmark plutus-benchmark:validation

@effectfully effectfully force-pushed the effectfully/builtins/evaluation/inlinable-geq branch from 918afb6 to 4c085ec Compare February 15, 2023 18:17
@effectfully effectfully marked this pull request as ready for review February 15, 2023 18:37
@effectfully
Copy link
Contributor Author

Ready for review, but the benchmarking runner is not with us anymore.

@effectfully effectfully force-pushed the effectfully/builtins/evaluation/inlinable-geq branch from 4c085ec to 91c1242 Compare February 15, 2023 18:40
@michaelpj
Copy link
Contributor

cc @zeme-iohk the benchmarking job seems to have got stuck in a queue? https://github.com/input-output-hk/plutus/actions/runs/4186578896

Is the runner accepting jobs?

@michaelpj michaelpj merged commit 02d518e into master Feb 16, 2023
@michaelpj michaelpj deleted the effectfully/builtins/evaluation/inlinable-geq branch February 16, 2023 11:28
@michaelpj
Copy link
Contributor

image

@zeme-iohk
Copy link

cc @zeme-iohk the benchmarking job seems to have got stuck in a queue? https://github.com/input-output-hk/plutus/actions/runs/4186578896

Is the runner accepting jobs?

The runner has been offline all day I'm afraid

v0d1ch pushed a commit to v0d1ch/plutus that referenced this pull request Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants