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

[Builtins] Replace a match on 'Refl' with a call to 'unsafeCoerce' #4400

Closed

Conversation

effectfully
Copy link
Contributor

Just being curious how much that redundant match on Refl costs us.

@effectfully effectfully added Builtins Performance EXPERIMENT Experiments that we probably don't want to merge labels Feb 12, 2022
@effectfully
Copy link
Contributor Author

/benchmark plutus-benchmark:validation

@iohk-devops
Copy link

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

Script afe6dcd d937da3 Change
auction_1-1 296.0 μs 304.7 μs +2.9%
auction_1-2 965.0 μs 979.7 μs +1.5%
auction_1-3 960.2 μs 982.6 μs +2.3%
auction_1-4 389.6 μs 401.5 μs +3.1%
auction_2-1 298.4 μs 307.5 μs +3.0%
auction_2-2 969.7 μs 982.0 μs +1.3%
auction_2-3 1.227 ms 1.249 ms +1.8%
auction_2-4 963.0 μs 979.6 μs +1.7%
auction_2-5 389.5 μs 399.6 μs +2.6%
crowdfunding-success-1 351.3 μs 360.3 μs +2.6%
crowdfunding-success-2 352.6 μs 359.9 μs +2.1%
crowdfunding-success-3 353.3 μs 360.2 μs +2.0%
currency-1 380.8 μs 388.6 μs +2.0%
escrow-redeem_1-1 560.4 μs 569.7 μs +1.7%
escrow-redeem_1-2 561.4 μs 569.2 μs +1.4%
escrow-redeem_2-1 652.2 μs 663.6 μs +1.7%
escrow-redeem_2-2 654.8 μs 664.7 μs +1.5%
escrow-redeem_2-3 652.9 μs 667.7 μs +2.3%
escrow-refund-1 260.5 μs 267.6 μs +2.7%
future-increase-margin-1 380.4 μs 389.7 μs +2.4%
future-increase-margin-2 846.6 μs 863.4 μs +2.0%
future-increase-margin-3 845.2 μs 862.0 μs +2.0%
future-increase-margin-4 773.5 μs 786.1 μs +1.6%
future-increase-margin-5 1.173 ms 1.190 ms +1.4%
future-pay-out-1 380.3 μs 388.2 μs +2.1%
future-pay-out-2 845.0 μs 861.4 μs +1.9%
future-pay-out-3 848.9 μs 861.5 μs +1.5%
future-pay-out-4 1.175 ms 1.184 ms +0.8%
future-settle-early-1 380.6 μs 386.3 μs +1.5%
future-settle-early-2 849.6 μs 859.0 μs +1.1%
future-settle-early-3 847.8 μs 862.8 μs +1.8%
future-settle-early-4 910.5 μs 923.4 μs +1.4%
game-sm-success_1-1 625.1 μs 633.8 μs +1.4%
game-sm-success_1-2 331.4 μs 340.5 μs +2.7%
game-sm-success_1-3 967.5 μs 983.2 μs +1.6%
game-sm-success_1-4 385.5 μs 395.6 μs +2.6%
game-sm-success_2-1 624.8 μs 635.0 μs +1.6%
game-sm-success_2-2 331.9 μs 341.5 μs +2.9%
game-sm-success_2-3 972.8 μs 989.7 μs +1.7%
game-sm-success_2-4 386.0 μs 398.1 μs +3.1%
game-sm-success_2-5 972.7 μs 986.2 μs +1.4%
game-sm-success_2-6 388.2 μs 396.8 μs +2.2%
multisig-sm-1 631.3 μs 638.4 μs +1.1%
multisig-sm-2 618.2 μs 623.8 μs +0.9%
multisig-sm-3 625.4 μs 631.8 μs +1.0%
multisig-sm-4 632.1 μs 639.0 μs +1.1%
multisig-sm-5 858.2 μs 865.5 μs +0.9%
multisig-sm-6 629.5 μs 635.9 μs +1.0%
multisig-sm-7 615.6 μs 622.2 μs +1.1%
multisig-sm-8 623.5 μs 632.7 μs +1.5%
multisig-sm-9 630.8 μs 639.9 μs +1.4%
multisig-sm-10 856.0 μs 867.3 μs +1.3%
ping-pong-1 522.4 μs 530.2 μs +1.5%
ping-pong-2 520.8 μs 529.1 μs +1.6%
ping-pong_2-1 323.8 μs 330.4 μs +2.0%
prism-1 277.5 μs 285.1 μs +2.7%
prism-2 674.6 μs 688.3 μs +2.0%
prism-3 583.0 μs 597.4 μs +2.5%
pubkey-1 233.7 μs 241.8 μs +3.5%
stablecoin_1-1 1.367 ms 1.400 ms +2.4%
stablecoin_1-2 324.0 μs 332.6 μs +2.7%
stablecoin_1-3 1.582 ms 1.601 ms +1.2%
stablecoin_1-4 345.8 μs 353.6 μs +2.3%
stablecoin_1-5 2.025 ms 2.045 ms +1.0%
stablecoin_1-6 427.4 μs 437.2 μs +2.3%
stablecoin_2-1 1.375 ms 1.385 ms +0.7%
stablecoin_2-2 323.1 μs 332.5 μs +2.9%
stablecoin_2-3 1.576 ms 1.594 ms +1.1%
stablecoin_2-4 344.7 μs 352.8 μs +2.3%
token-account-1 297.1 μs 302.2 μs +1.7%
token-account-2 517.3 μs 527.7 μs +2.0%
uniswap-1 612.5 μs 622.9 μs +1.7%
uniswap-2 356.2 μs 366.6 μs +2.9%
uniswap-3 2.584 ms 2.645 ms +2.4%
uniswap-4 567.5 μs 584.8 μs +3.0%
uniswap-5 1.823 ms 1.848 ms +1.4%
uniswap-6 541.4 μs 557.2 μs +2.9%
vesting-1 537.1 μs 545.4 μs +1.5%

@effectfully
Copy link
Contributor Author

???

@effectfully
Copy link
Contributor Author

I do not see any problems in Core, hence

/benchmark plutus-benchmark:validation

@effectfully
Copy link
Contributor Author

/benchmark plutus-benchmark:validation

@iohk-devops
Copy link

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

Script afe6dcd d937da3 Change
auction_1-1 296.0 μs 305.5 μs +3.2%
auction_1-2 965.6 μs 978.7 μs +1.4%
auction_1-3 962.6 μs 972.9 μs +1.1%
auction_1-4 388.9 μs 399.8 μs +2.8%
auction_2-1 297.5 μs 306.4 μs +3.0%
auction_2-2 964.4 μs 983.9 μs +2.0%
auction_2-3 1.224 ms 1.246 ms +1.8%
auction_2-4 959.6 μs 977.0 μs +1.8%
auction_2-5 389.2 μs 400.5 μs +2.9%
crowdfunding-success-1 350.3 μs 361.0 μs +3.1%
crowdfunding-success-2 350.6 μs 360.7 μs +2.9%
crowdfunding-success-3 350.6 μs 361.2 μs +3.0%
currency-1 381.2 μs 388.2 μs +1.8%
escrow-redeem_1-1 560.8 μs 569.2 μs +1.5%
escrow-redeem_1-2 559.8 μs 568.6 μs +1.6%
escrow-redeem_2-1 651.4 μs 665.5 μs +2.2%
escrow-redeem_2-2 653.6 μs 664.5 μs +1.7%
escrow-redeem_2-3 650.8 μs 663.3 μs +1.9%
escrow-refund-1 260.2 μs 265.6 μs +2.1%
future-increase-margin-1 380.6 μs 388.3 μs +2.0%
future-increase-margin-2 843.6 μs 861.0 μs +2.1%
future-increase-margin-3 840.9 μs 862.1 μs +2.5%
future-increase-margin-4 770.3 μs 789.1 μs +2.4%
future-increase-margin-5 1.174 ms 1.197 ms +2.0%
future-pay-out-1 380.0 μs 389.8 μs +2.6%
future-pay-out-2 846.1 μs 861.9 μs +1.9%
future-pay-out-3 844.5 μs 865.6 μs +2.5%
future-pay-out-4 1.166 ms 1.189 ms +2.0%
future-settle-early-1 379.4 μs 387.4 μs +2.1%
future-settle-early-2 846.8 μs 859.3 μs +1.5%
future-settle-early-3 850.5 μs 859.9 μs +1.1%
future-settle-early-4 911.1 μs 920.3 μs +1.0%
game-sm-success_1-1 625.5 μs 631.7 μs +1.0%
game-sm-success_1-2 331.2 μs 338.8 μs +2.3%
game-sm-success_1-3 973.9 μs 983.9 μs +1.0%
game-sm-success_1-4 385.3 μs 396.5 μs +2.9%
game-sm-success_2-1 622.9 μs 633.2 μs +1.7%
game-sm-success_2-2 329.7 μs 339.9 μs +3.1%
game-sm-success_2-3 967.4 μs 982.0 μs +1.5%
game-sm-success_2-4 384.8 μs 397.5 μs +3.3%
game-sm-success_2-5 971.3 μs 987.6 μs +1.7%
game-sm-success_2-6 385.5 μs 398.8 μs +3.5%
multisig-sm-1 627.1 μs 639.5 μs +2.0%
multisig-sm-2 614.0 μs 624.5 μs +1.7%
multisig-sm-3 622.0 μs 633.1 μs +1.8%
multisig-sm-4 630.4 μs 640.4 μs +1.6%
multisig-sm-5 858.3 μs 866.9 μs +1.0%
multisig-sm-6 628.8 μs 635.9 μs +1.1%
multisig-sm-7 615.8 μs 621.2 μs +0.9%
multisig-sm-8 624.4 μs 631.5 μs +1.1%
multisig-sm-9 630.7 μs 639.5 μs +1.4%
multisig-sm-10 852.2 μs 866.8 μs +1.7%
ping-pong-1 519.0 μs 529.8 μs +2.1%
ping-pong-2 519.8 μs 530.1 μs +2.0%
ping-pong_2-1 321.7 μs 331.3 μs +3.0%
prism-1 274.9 μs 284.5 μs +3.5%
prism-2 672.0 μs 687.1 μs +2.2%
prism-3 580.2 μs 594.7 μs +2.5%
pubkey-1 234.0 μs 241.1 μs +3.0%
stablecoin_1-1 1.363 ms 1.393 ms +2.2%
stablecoin_1-2 321.0 μs 333.2 μs +3.8%
stablecoin_1-3 1.568 ms 1.605 ms +2.4%
stablecoin_1-4 342.5 μs 353.6 μs +3.2%
stablecoin_1-5 2.015 ms 2.057 ms +2.1%
stablecoin_1-6 426.5 μs 438.8 μs +2.9%
stablecoin_2-1 1.373 ms 1.393 ms +1.5%
stablecoin_2-2 322.3 μs 331.7 μs +2.9%
stablecoin_2-3 1.575 ms 1.593 ms +1.1%
stablecoin_2-4 343.3 μs 353.1 μs +2.9%
token-account-1 296.7 μs 303.6 μs +2.3%
token-account-2 517.3 μs 527.7 μs +2.0%
uniswap-1 611.7 μs 620.3 μs +1.4%
uniswap-2 355.7 μs 365.1 μs +2.6%
uniswap-3 2.580 ms 2.636 ms +2.2%
uniswap-4 565.7 μs 584.3 μs +3.3%
uniswap-5 1.812 ms 1.858 ms +2.5%
uniswap-6 538.2 μs 556.8 μs +3.5%
vesting-1 533.7 μs 546.6 μs +2.4%

@effectfully
Copy link
Contributor Author

A mystery.

@effectfully effectfully deleted the effectfully/builtins/remove-a-match-on-Refl branch February 13, 2022 14:33
@michaelpj
Copy link
Contributor

I think unsafeCoerce probably inhibits a bunch of optimization, which might explain why this is worse.

@effectfully
Copy link
Contributor Author

It's unsafeCoerce around a single variable and it doesn't end up in the Core from what I can tell, so I've no idea what's going on here. In any case, the match on Refl is gone in #4380.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Builtins EXPERIMENT Experiments that we probably don't want to merge Performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants