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] Disentangle 'KnownTypeAst' from 'KnownTypeIn' #4312

Merged

Conversation

effectfully
Copy link
Contributor

Do not look here yet.

@effectfully
Copy link
Contributor Author

/benchmark

@iohk-devops
Copy link

Comparing benchmark results of 'c876b1530' (base) and 'c1beb8a0b' (PR)

Script c876b15 c1beb8a Change
auction_1-1 322.6 μs 325.5 μs +0.9%
auction_1-2 1.067 ms 1.075 ms +0.7%
auction_1-3 1.069 ms 1.078 ms +0.8%
auction_1-4 424.7 μs 428.5 μs +0.9%
auction_2-1 326.5 μs 326.5 μs 0.0%
auction_2-2 1.070 ms 1.072 ms +0.2%
auction_2-3 1.353 ms 1.353 ms 0.0%
auction_2-4 1.070 ms 1.072 ms +0.2%
auction_2-5 424.4 μs 427.4 μs +0.7%
crowdfunding-success-1 380.0 μs 385.1 μs +1.3%
crowdfunding-success-2 381.0 μs 385.6 μs +1.2%
crowdfunding-success-3 380.9 μs 386.5 μs +1.5%
currency-1 416.2 μs 418.2 μs +0.5%
escrow-redeem_1-1 624.5 μs 627.1 μs +0.4%
escrow-redeem_1-2 623.3 μs 626.4 μs +0.5%
escrow-redeem_2-1 660.1 μs 667.6 μs +1.1%
escrow-redeem_2-2 662.3 μs 668.5 μs +0.9%
escrow-redeem_2-3 662.6 μs 667.5 μs +0.7%
escrow-refund-1 286.9 μs 290.2 μs +1.2%
future-increase-margin-1 415.4 μs 419.3 μs +0.9%
future-increase-margin-2 938.9 μs 941.3 μs +0.3%
future-increase-margin-3 937.7 μs 939.6 μs +0.2%
future-increase-margin-4 876.9 μs 869.9 μs -0.8%
future-increase-margin-5 1.304 ms 1.304 ms 0.0%
future-pay-out-1 415.9 μs 420.0 μs +1.0%
future-pay-out-2 940.7 μs 943.8 μs +0.3%
future-pay-out-3 937.0 μs 942.2 μs +0.6%
future-pay-out-4 1.299 ms 1.303 ms +0.3%
future-settle-early-1 415.7 μs 419.1 μs +0.8%
future-settle-early-2 939.0 μs 948.1 μs +1.0%
future-settle-early-3 940.0 μs 944.7 μs +0.5%
future-settle-early-4 1.015 ms 1.017 ms +0.2%
game-sm-success_1-1 697.5 μs 701.0 μs +0.5%
game-sm-success_1-2 360.9 μs 364.8 μs +1.1%
game-sm-success_1-3 1.075 ms 1.076 ms +0.1%
game-sm-success_1-4 423.7 μs 426.2 μs +0.6%
game-sm-success_2-1 699.9 μs 699.9 μs 0.0%
game-sm-success_2-2 362.7 μs 365.1 μs +0.7%
game-sm-success_2-3 1.081 ms 1.078 ms -0.3%
game-sm-success_2-4 422.9 μs 425.4 μs +0.6%
game-sm-success_2-5 1.076 ms 1.082 ms +0.6%
game-sm-success_2-6 422.0 μs 428.0 μs +1.4%
multisig-sm-1 707.3 μs 712.9 μs +0.8%
multisig-sm-2 692.4 μs 700.9 μs +1.2%
multisig-sm-3 699.1 μs 707.2 μs +1.2%
multisig-sm-4 707.8 μs 712.2 μs +0.6%
multisig-sm-5 958.5 μs 959.6 μs +0.1%
multisig-sm-6 709.6 μs 712.9 μs +0.5%
multisig-sm-7 695.4 μs 698.8 μs +0.5%
multisig-sm-8 702.2 μs 706.0 μs +0.5%
multisig-sm-9 707.7 μs 713.5 μs +0.8%
multisig-sm-10 955.4 μs 957.8 μs +0.3%
ping-pong-1 578.5 μs 580.0 μs +0.3%
ping-pong-2 579.2 μs 580.4 μs +0.2%
ping-pong_2-1 357.6 μs 359.9 μs +0.6%
prism-1 298.8 μs 302.5 μs +1.2%
prism-2 761.4 μs 763.5 μs +0.3%
prism-3 642.9 μs 644.8 μs +0.3%
pubkey-1 257.2 μs 259.3 μs +0.8%
stablecoin_1-1 1.488 ms 1.488 ms 0.0%
stablecoin_1-2 354.5 μs 358.3 μs +1.1%
stablecoin_1-3 1.695 ms 1.696 ms +0.1%
stablecoin_1-4 375.4 μs 379.8 μs +1.2%
stablecoin_1-5 2.137 ms 2.146 ms +0.4%
stablecoin_1-6 465.8 μs 470.7 μs +1.1%
stablecoin_2-1 1.483 ms 1.493 ms +0.7%
stablecoin_2-2 352.8 μs 358.3 μs +1.6%
stablecoin_2-3 1.683 ms 1.694 ms +0.7%
stablecoin_2-4 374.0 μs 379.2 μs +1.4%
token-account-1 321.4 μs 324.7 μs +1.0%
token-account-2 574.8 μs 578.3 μs +0.6%
uniswap-1 676.4 μs 676.9 μs +0.1%
uniswap-2 388.2 μs 392.2 μs +1.0%
uniswap-3 2.720 ms 2.723 ms +0.1%
uniswap-4 614.7 μs 623.1 μs +1.4%
uniswap-5 1.930 ms 1.933 ms +0.2%
uniswap-6 587.4 μs 593.2 μs +1.0%
vesting-1 602.1 μs 598.4 μs -0.6%

@effectfully effectfully force-pushed the effectfully/disentangle-KnownTypeAst-from-KnownTypeIn branch from 889e799 to 20fd9d8 Compare January 5, 2022 13:14
@effectfully
Copy link
Contributor Author

/benchmark

@iohk-devops
Copy link

Comparing benchmark results of 'c876b1530' (base) and '20fd9d80e' (PR)

Script c876b15 20fd9d8 Change
auction_1-1 323.0 μs 329.0 μs +1.9%
auction_1-2 1.067 ms 1.069 ms +0.2%
auction_1-3 1.069 ms 1.069 ms 0.0%
auction_1-4 424.3 μs 431.3 μs +1.6%
auction_2-1 323.3 μs 330.7 μs +2.3%
auction_2-2 1.065 ms 1.070 ms +0.5%
auction_2-3 1.347 ms 1.358 ms +0.8%
auction_2-4 1.068 ms 1.073 ms +0.5%
auction_2-5 424.0 μs 432.7 μs +2.1%
crowdfunding-success-1 381.1 μs 388.9 μs +2.0%
crowdfunding-success-2 380.4 μs 388.2 μs +2.1%
crowdfunding-success-3 381.5 μs 387.6 μs +1.6%
currency-1 415.9 μs 421.3 μs +1.3%
escrow-redeem_1-1 624.9 μs 629.4 μs +0.7%
escrow-redeem_1-2 626.0 μs 629.1 μs +0.5%
escrow-redeem_2-1 666.4 μs 666.4 μs 0.0%
escrow-redeem_2-2 664.7 μs 667.2 μs +0.4%
escrow-redeem_2-3 662.9 μs 666.3 μs +0.5%
escrow-refund-1 285.8 μs 290.7 μs +1.7%
future-increase-margin-1 416.9 μs 424.1 μs +1.7%
future-increase-margin-2 938.9 μs 947.8 μs +0.9%
future-increase-margin-3 936.6 μs 944.8 μs +0.9%
future-increase-margin-4 874.9 μs 873.1 μs -0.2%
future-increase-margin-5 1.304 ms 1.294 ms -0.8%
future-pay-out-1 416.1 μs 421.9 μs +1.4%
future-pay-out-2 943.1 μs 945.9 μs +0.3%
future-pay-out-3 938.2 μs 942.6 μs +0.5%
future-pay-out-4 1.306 ms 1.299 ms -0.5%
future-settle-early-1 418.4 μs 421.0 μs +0.6%
future-settle-early-2 945.0 μs 942.4 μs -0.3%
future-settle-early-3 942.1 μs 943.3 μs +0.1%
future-settle-early-4 1.017 ms 1.012 ms -0.5%
game-sm-success_1-1 699.1 μs 698.2 μs -0.1%
game-sm-success_1-2 362.6 μs 368.0 μs +1.5%
game-sm-success_1-3 1.076 ms 1.073 ms -0.3%
game-sm-success_1-4 423.4 μs 428.9 μs +1.3%
game-sm-success_2-1 699.0 μs 698.4 μs -0.1%
game-sm-success_2-2 362.5 μs 368.4 μs +1.6%
game-sm-success_2-3 1.077 ms 1.076 ms -0.1%
game-sm-success_2-4 423.0 μs 428.6 μs +1.3%
game-sm-success_2-5 1.076 ms 1.073 ms -0.3%
game-sm-success_2-6 424.1 μs 428.4 μs +1.0%
multisig-sm-1 712.6 μs 711.9 μs -0.1%
multisig-sm-2 697.2 μs 698.9 μs +0.2%
multisig-sm-3 705.8 μs 705.0 μs -0.1%
multisig-sm-4 711.6 μs 710.9 μs -0.1%
multisig-sm-5 963.1 μs 958.1 μs -0.5%
multisig-sm-6 711.6 μs 711.5 μs -0.0%
multisig-sm-7 696.2 μs 699.1 μs +0.4%
multisig-sm-8 704.3 μs 708.2 μs +0.6%
multisig-sm-9 713.4 μs 716.0 μs +0.4%
multisig-sm-10 959.6 μs 960.2 μs +0.1%
ping-pong-1 580.3 μs 578.0 μs -0.4%
ping-pong-2 579.7 μs 580.7 μs +0.2%
ping-pong_2-1 357.6 μs 360.2 μs +0.7%
prism-1 298.6 μs 304.3 μs +1.9%
prism-2 760.1 μs 769.4 μs +1.2%
prism-3 641.4 μs 650.0 μs +1.3%
pubkey-1 256.9 μs 262.0 μs +2.0%
stablecoin_1-1 1.493 ms 1.499 ms +0.4%
stablecoin_1-2 354.6 μs 359.6 μs +1.4%
stablecoin_1-3 1.691 ms 1.703 ms +0.7%
stablecoin_1-4 375.4 μs 380.7 μs +1.4%
stablecoin_1-5 2.130 ms 2.145 ms +0.7%
stablecoin_1-6 464.9 μs 470.8 μs +1.3%
stablecoin_2-1 1.487 ms 1.492 ms +0.3%
stablecoin_2-2 353.7 μs 358.3 μs +1.3%
stablecoin_2-3 1.692 ms 1.702 ms +0.6%
stablecoin_2-4 376.4 μs 380.2 μs +1.0%
token-account-1 324.6 μs 325.3 μs +0.2%
token-account-2 575.8 μs 577.5 μs +0.3%
uniswap-1 678.9 μs 678.8 μs -0.0%
uniswap-2 389.1 μs 393.4 μs +1.1%
uniswap-3 2.720 ms 2.713 ms -0.3%
uniswap-4 614.4 μs 625.9 μs +1.9%
uniswap-5 1.928 ms 1.936 ms +0.4%
uniswap-6 585.0 μs 598.9 μs +2.4%
vesting-1 597.1 μs 604.4 μs +1.2%

@effectfully
Copy link
Contributor Author

/benchmark

@iohk-devops
Copy link

Comparing benchmark results of 'c876b1530' (base) and '4693b29bf' (PR)

Script c876b15 4693b29 Change
auction_1-1 323.2 μs 325.5 μs +0.7%
auction_1-2 1.063 ms 1.066 ms +0.3%
auction_1-3 1.067 ms 1.068 ms +0.1%
auction_1-4 424.0 μs 427.6 μs +0.8%
auction_2-1 326.7 μs 326.7 μs 0.0%
auction_2-2 1.068 ms 1.071 ms +0.3%
auction_2-3 1.348 ms 1.352 ms +0.3%
auction_2-4 1.067 ms 1.070 ms +0.3%
auction_2-5 423.0 μs 428.2 μs +1.2%
crowdfunding-success-1 379.7 μs 384.2 μs +1.2%
crowdfunding-success-2 381.3 μs 384.8 μs +0.9%
crowdfunding-success-3 382.4 μs 384.0 μs +0.4%
currency-1 417.0 μs 416.4 μs -0.1%
escrow-redeem_1-1 625.8 μs 621.7 μs -0.7%
escrow-redeem_1-2 625.3 μs 620.6 μs -0.8%
escrow-redeem_2-1 663.4 μs 659.8 μs -0.5%
escrow-redeem_2-2 664.1 μs 660.0 μs -0.6%
escrow-redeem_2-3 661.9 μs 659.7 μs -0.3%
escrow-refund-1 286.5 μs 286.9 μs +0.1%
future-increase-margin-1 415.9 μs 416.5 μs +0.1%
future-increase-margin-2 938.5 μs 933.7 μs -0.5%
future-increase-margin-3 938.3 μs 935.5 μs -0.3%
future-increase-margin-4 873.2 μs 873.0 μs -0.0%
future-increase-margin-5 1.302 ms 1.301 ms -0.1%
future-pay-out-1 415.6 μs 416.5 μs +0.2%
future-pay-out-2 942.1 μs 936.7 μs -0.6%
future-pay-out-3 940.1 μs 933.0 μs -0.8%
future-pay-out-4 1.306 ms 1.294 ms -0.9%
future-settle-early-1 418.4 μs 415.9 μs -0.6%
future-settle-early-2 940.7 μs 932.5 μs -0.9%
future-settle-early-3 939.4 μs 933.8 μs -0.6%
future-settle-early-4 1.017 ms 1.015 ms -0.2%
game-sm-success_1-1 697.6 μs 696.4 μs -0.2%
game-sm-success_1-2 360.3 μs 362.8 μs +0.7%
game-sm-success_1-3 1.078 ms 1.070 ms -0.7%
game-sm-success_1-4 423.8 μs 423.0 μs -0.2%
game-sm-success_2-1 697.3 μs 697.8 μs +0.1%
game-sm-success_2-2 361.2 μs 363.8 μs +0.7%
game-sm-success_2-3 1.076 ms 1.073 ms -0.3%
game-sm-success_2-4 423.4 μs 424.0 μs +0.1%
game-sm-success_2-5 1.077 ms 1.073 ms -0.4%
game-sm-success_2-6 422.9 μs 424.2 μs +0.3%
multisig-sm-1 710.8 μs 707.9 μs -0.4%
multisig-sm-2 695.2 μs 692.2 μs -0.4%
multisig-sm-3 703.0 μs 700.9 μs -0.3%
multisig-sm-4 710.7 μs 707.1 μs -0.5%
multisig-sm-5 957.9 μs 954.2 μs -0.4%
multisig-sm-6 709.9 μs 706.8 μs -0.4%
multisig-sm-7 694.1 μs 695.0 μs +0.1%
multisig-sm-8 702.6 μs 701.5 μs -0.2%
multisig-sm-9 709.9 μs 709.8 μs -0.0%
multisig-sm-10 958.0 μs 953.8 μs -0.4%
ping-pong-1 578.9 μs 575.3 μs -0.6%
ping-pong-2 580.2 μs 576.8 μs -0.6%
ping-pong_2-1 357.2 μs 356.8 μs -0.1%
prism-1 299.9 μs 302.2 μs +0.8%
prism-2 761.4 μs 762.1 μs +0.1%
prism-3 639.3 μs 640.5 μs +0.2%
pubkey-1 256.7 μs 258.3 μs +0.6%
stablecoin_1-1 1.487 ms 1.487 ms 0.0%
stablecoin_1-2 352.1 μs 355.0 μs +0.8%
stablecoin_1-3 1.695 ms 1.694 ms -0.1%
stablecoin_1-4 376.4 μs 376.6 μs +0.1%
stablecoin_1-5 2.139 ms 2.137 ms -0.1%
stablecoin_1-6 465.6 μs 467.1 μs +0.3%
stablecoin_2-1 1.486 ms 1.485 ms -0.1%
stablecoin_2-2 352.3 μs 354.7 μs +0.7%
stablecoin_2-3 1.688 ms 1.689 ms +0.1%
stablecoin_2-4 373.6 μs 375.7 μs +0.6%
token-account-1 321.0 μs 323.0 μs +0.6%
token-account-2 573.4 μs 574.7 μs +0.2%
uniswap-1 674.7 μs 675.8 μs +0.2%
uniswap-2 386.3 μs 391.7 μs +1.4%
uniswap-3 2.715 ms 2.725 ms +0.4%
uniswap-4 614.3 μs 618.8 μs +0.7%
uniswap-5 1.927 ms 1.932 ms +0.3%
uniswap-6 585.3 μs 588.4 μs +0.5%
vesting-1 597.3 μs 596.9 μs -0.1%

@effectfully
Copy link
Contributor Author

/benchmark

@iohk-devops
Copy link

Comparing benchmark results of 'c876b1530' (base) and 'c42a9f252' (PR)

Script c876b15 c42a9f2 Change
auction_1-1 323.6 μs 323.5 μs -0.0%
auction_1-2 1.068 ms 1.070 ms +0.2%
auction_1-3 1.069 ms 1.075 ms +0.6%
auction_1-4 425.2 μs 424.8 μs -0.1%
auction_2-1 326.5 μs 325.9 μs -0.2%
auction_2-2 1.072 ms 1.070 ms -0.2%
auction_2-3 1.353 ms 1.353 ms 0.0%
auction_2-4 1.074 ms 1.070 ms -0.4%
auction_2-5 425.2 μs 423.4 μs -0.4%
crowdfunding-success-1 381.4 μs 381.7 μs +0.1%
crowdfunding-success-2 381.7 μs 380.7 μs -0.3%
crowdfunding-success-3 381.1 μs 381.9 μs +0.2%
currency-1 415.8 μs 418.4 μs +0.6%
escrow-redeem_1-1 624.1 μs 626.8 μs +0.4%
escrow-redeem_1-2 623.0 μs 625.8 μs +0.4%
escrow-redeem_2-1 663.2 μs 663.7 μs +0.1%
escrow-redeem_2-2 663.7 μs 662.4 μs -0.2%
escrow-redeem_2-3 663.3 μs 666.2 μs +0.4%
escrow-refund-1 287.1 μs 288.9 μs +0.6%
future-increase-margin-1 416.1 μs 417.8 μs +0.4%
future-increase-margin-2 942.3 μs 940.6 μs -0.2%
future-increase-margin-3 939.2 μs 939.8 μs +0.1%
future-increase-margin-4 875.5 μs 866.7 μs -1.0%
future-increase-margin-5 1.307 ms 1.298 ms -0.7%
future-pay-out-1 418.3 μs 417.9 μs -0.1%
future-pay-out-2 941.6 μs 937.5 μs -0.4%
future-pay-out-3 941.0 μs 942.0 μs +0.1%
future-pay-out-4 1.304 ms 1.298 ms -0.5%
future-settle-early-1 416.0 μs 418.1 μs +0.5%
future-settle-early-2 941.8 μs 939.5 μs -0.2%
future-settle-early-3 940.0 μs 943.4 μs +0.4%
future-settle-early-4 1.017 ms 1.017 ms 0.0%
game-sm-success_1-1 696.7 μs 700.1 μs +0.5%
game-sm-success_1-2 361.2 μs 363.6 μs +0.7%
game-sm-success_1-3 1.082 ms 1.079 ms -0.3%
game-sm-success_1-4 425.4 μs 424.3 μs -0.3%
game-sm-success_2-1 699.7 μs 698.3 μs -0.2%
game-sm-success_2-2 362.4 μs 362.6 μs +0.1%
game-sm-success_2-3 1.080 ms 1.077 ms -0.3%
game-sm-success_2-4 422.9 μs 423.9 μs +0.2%
game-sm-success_2-5 1.078 ms 1.077 ms -0.1%
game-sm-success_2-6 422.0 μs 423.7 μs +0.4%
multisig-sm-1 708.9 μs 708.8 μs -0.0%
multisig-sm-2 694.5 μs 694.4 μs -0.0%
multisig-sm-3 702.2 μs 702.4 μs +0.0%
multisig-sm-4 710.7 μs 709.7 μs -0.1%
multisig-sm-5 959.1 μs 957.4 μs -0.2%
multisig-sm-6 708.9 μs 709.6 μs +0.1%
multisig-sm-7 696.0 μs 695.2 μs -0.1%
multisig-sm-8 702.9 μs 706.4 μs +0.5%
multisig-sm-9 709.7 μs 713.6 μs +0.5%
multisig-sm-10 957.1 μs 956.8 μs -0.0%
ping-pong-1 578.8 μs 581.4 μs +0.4%
ping-pong-2 579.7 μs 582.0 μs +0.4%
ping-pong_2-1 357.4 μs 358.9 μs +0.4%
prism-1 295.8 μs 301.3 μs +1.9%
prism-2 763.5 μs 761.8 μs -0.2%
prism-3 642.8 μs 642.4 μs -0.1%
pubkey-1 257.6 μs 257.0 μs -0.2%
stablecoin_1-1 1.495 ms 1.489 ms -0.4%
stablecoin_1-2 355.0 μs 354.1 μs -0.3%
stablecoin_1-3 1.701 ms 1.692 ms -0.5%
stablecoin_1-4 376.3 μs 375.7 μs -0.2%
stablecoin_1-5 2.138 ms 2.139 ms +0.0%
stablecoin_1-6 465.2 μs 467.7 μs +0.5%
stablecoin_2-1 1.490 ms 1.488 ms -0.1%
stablecoin_2-2 353.4 μs 353.8 μs +0.1%
stablecoin_2-3 1.691 ms 1.691 ms 0.0%
stablecoin_2-4 374.7 μs 375.0 μs +0.1%
token-account-1 321.6 μs 323.4 μs +0.6%
token-account-2 573.9 μs 578.0 μs +0.7%
uniswap-1 675.2 μs 680.3 μs +0.8%
uniswap-2 388.8 μs 391.7 μs +0.7%
uniswap-3 2.728 ms 2.734 ms +0.2%
uniswap-4 617.3 μs 620.0 μs +0.4%
uniswap-5 1.933 ms 1.934 ms +0.1%
uniswap-6 585.8 μs 590.0 μs +0.7%
vesting-1 597.5 μs 601.7 μs +0.7%

@effectfully
Copy link
Contributor Author

/benchmark

@iohk-devops
Copy link

Comparing benchmark results of 'c876b1530' (base) and '7d3c855f4' (PR)

Script c876b15 7d3c855 Change
auction_1-1 323.1 μs 321.2 μs -0.6%
auction_1-2 1.073 ms 1.065 ms -0.7%
auction_1-3 1.076 ms 1.066 ms -0.9%
auction_1-4 425.0 μs 422.1 μs -0.7%
auction_2-1 323.7 μs 322.7 μs -0.3%
auction_2-2 1.069 ms 1.064 ms -0.5%
auction_2-3 1.350 ms 1.344 ms -0.4%
auction_2-4 1.072 ms 1.069 ms -0.3%
auction_2-5 423.2 μs 423.4 μs +0.0%
crowdfunding-success-1 379.9 μs 382.1 μs +0.6%
crowdfunding-success-2 379.9 μs 382.0 μs +0.6%
crowdfunding-success-3 380.2 μs 384.3 μs +1.1%
currency-1 415.2 μs 420.0 μs +1.2%
escrow-redeem_1-1 623.6 μs 629.5 μs +0.9%
escrow-redeem_1-2 626.2 μs 627.7 μs +0.2%
escrow-redeem_2-1 663.2 μs 665.2 μs +0.3%
escrow-redeem_2-2 659.7 μs 666.5 μs +1.0%
escrow-redeem_2-3 661.2 μs 664.1 μs +0.4%
escrow-refund-1 286.4 μs 287.5 μs +0.4%
future-increase-margin-1 417.2 μs 417.3 μs +0.0%
future-increase-margin-2 941.7 μs 941.8 μs +0.0%
future-increase-margin-3 938.6 μs 939.7 μs +0.1%
future-increase-margin-4 876.8 μs 870.6 μs -0.7%
future-increase-margin-5 1.301 ms 1.297 ms -0.3%
future-pay-out-1 416.4 μs 417.8 μs +0.3%
future-pay-out-2 938.2 μs 943.2 μs +0.5%
future-pay-out-3 936.8 μs 941.9 μs +0.5%
future-pay-out-4 1.300 ms 1.302 ms +0.2%
future-settle-early-1 416.5 μs 418.2 μs +0.4%
future-settle-early-2 940.2 μs 941.3 μs +0.1%
future-settle-early-3 939.3 μs 942.5 μs +0.3%
future-settle-early-4 1.015 ms 1.014 ms -0.1%
game-sm-success_1-1 700.2 μs 698.2 μs -0.3%
game-sm-success_1-2 362.7 μs 364.7 μs +0.6%
game-sm-success_1-3 1.078 ms 1.075 ms -0.3%
game-sm-success_1-4 424.2 μs 426.8 μs +0.6%
game-sm-success_2-1 698.0 μs 698.4 μs +0.1%
game-sm-success_2-2 361.1 μs 363.9 μs +0.8%
game-sm-success_2-3 1.076 ms 1.080 ms +0.4%
game-sm-success_2-4 422.8 μs 428.4 μs +1.3%
game-sm-success_2-5 1.075 ms 1.077 ms +0.2%
game-sm-success_2-6 420.5 μs 426.3 μs +1.4%
multisig-sm-1 707.8 μs 712.8 μs +0.7%
multisig-sm-2 696.5 μs 696.5 μs 0.0%
multisig-sm-3 703.8 μs 704.7 μs +0.1%
multisig-sm-4 710.5 μs 711.4 μs +0.1%
multisig-sm-5 960.7 μs 955.9 μs -0.5%
multisig-sm-6 709.4 μs 711.0 μs +0.2%
multisig-sm-7 693.8 μs 696.0 μs +0.3%
multisig-sm-8 704.0 μs 703.7 μs -0.0%
multisig-sm-9 708.5 μs 710.8 μs +0.3%
multisig-sm-10 957.8 μs 956.2 μs -0.2%
ping-pong-1 578.5 μs 581.1 μs +0.4%
ping-pong-2 580.4 μs 579.1 μs -0.2%
ping-pong_2-1 357.4 μs 359.0 μs +0.4%
prism-1 298.2 μs 300.2 μs +0.7%
prism-2 763.4 μs 761.6 μs -0.2%
prism-3 642.7 μs 643.4 μs +0.1%
pubkey-1 257.2 μs 257.5 μs +0.1%
stablecoin_1-1 1.489 ms 1.488 ms -0.1%
stablecoin_1-2 353.6 μs 355.5 μs +0.5%
stablecoin_1-3 1.690 ms 1.696 ms +0.4%
stablecoin_1-4 374.6 μs 377.8 μs +0.9%
stablecoin_1-5 2.132 ms 2.139 ms +0.3%
stablecoin_1-6 464.8 μs 470.6 μs +1.2%
stablecoin_2-1 1.485 ms 1.493 ms +0.5%
stablecoin_2-2 352.3 μs 357.0 μs +1.3%
stablecoin_2-3 1.691 ms 1.696 ms +0.3%
stablecoin_2-4 374.8 μs 377.8 μs +0.8%
token-account-1 321.2 μs 323.9 μs +0.8%
token-account-2 575.0 μs 575.9 μs +0.2%
uniswap-1 676.6 μs 678.6 μs +0.3%
uniswap-2 388.0 μs 389.4 μs +0.4%
uniswap-3 2.729 ms 2.726 ms -0.1%
uniswap-4 616.6 μs 619.2 μs +0.4%
uniswap-5 1.940 ms 1.945 ms +0.3%
uniswap-6 587.0 μs 590.5 μs +0.6%
vesting-1 600.7 μs 597.7 μs -0.5%

Comment on lines -182 to +185
(Prelude.id
:: a ~ Opaque term (TyAppRep (TyVarRep ('TyNameRep "f" 0)) Integer)
=> a -> a)
(Prelude.id :: fi ~ Opaque term (TyAppRep f Integer) => fi -> fi)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The inference machinery now is able to look under TyAppRep

Comment on lines -189 to +190
(Prelude.id
:: a ~ Opaque term (PlcListRep (TyVarRep ('TyNameRep "a" 0)))
=> a -> a)
(Prelude.id :: la ~ Opaque term (PlcListRep a) => la -> la)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

and basically any

Comment on lines -197 to +196
:: ( f ~ 'TyNameRep "f" 0
, a ~ 'TyNameRep @GHC.Type "a" 1
, afa ~ Opaque term (TyForallRep a (TyAppRep (TyVarRep f) (TyVarRep a)))
)
:: afa ~ Opaque term (TyForallRep a (TyAppRep (TyVarRep f) (TyVarRep a)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

other *Rep.

Comment on lines -247 to +260
-> SomeConstantPoly uni (,) '[a, b]
-> SomeConstant uni (a, b)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Quite nicer, isn't it?

Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of the file does look quite a bit more readable.

Comment on lines -25 to -26
-- >>> :t enumerateDebug $ Just 'a'
-- enumerateDebug $ Just 'a' :: Maybe Char
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to drop it, 'cause it now generates a ton of garbage instead of being stuck. I'll work on it some time later.

Comment on lines -334 to -339
-- This constraint is just to get through 'KnownPolytype' stuck on an unknown type straight
-- to the custom type error that we have in the @Typed@ module. Though, somehow, the error
-- gets triggered even without the constraint when this function in used, but I don't
-- understand how that is possible and it does not work when the function from the @Debug@
-- module is used. So we're just doing the right thing here and adding the constraint.
, KnownMonotype term args res a
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was used to trigger the now-dropped custom type error.

-- Try to unify @a@ with a freshly created @var@.
, a ~?~ var
-- If @a@ is equal to @var@ then unification was successful and we just used the fresh id and
-- so we need to bump it up. Otherwise @var@ was discarded and so the fresh id is still fresh.
-- Replacing @(===)@ with @(==)@ causes errors at use site, for whatever reason.
, j ~ If (a === var) (i + 1) i
) => TrySpecializeAsVar i j term a

-- | For looking under special-case types, for example the type of a constant or the type arguments
Copy link
Contributor Author

Choose a reason for hiding this comment

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

master:
Screenshot from 2022-01-07 22-42-36

this branch:
Screenshot from 2022-01-07 22-43-04

-- @i@ is a fresh id and @j@ is a final one as in 'TrySpecializeAsVar', but since 'HandleHole' can
-- specialize multiple variables, @j@ can be equal to @i + n@ for any @n@ (including @0@).
type SpecializeFromTo :: Nat -> Nat -> GHC.Type -> GHC.Type -> GHC.Constraint
type SpecializeFromTo i j term a = HandleHole i j term (TypeHole a)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michaelpj renamed EnumerateFromTo to SpecializeFromTo as requested.

@@ -457,39 +457,163 @@ type HasConstant term = (AsConstant term, FromConstant term)
-- and connects @term@ and its @uni@.
type HasConstantIn uni term = (UniOf term ~ uni, HasConstant term)

{- Note [Rep vs Type context]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There has always been the distinction, but I'm only documenting it now.

(fun (con integer) (fun [ (con list) (con data) ] (con data)))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This diff represents what the PR changes. Now we handle built-in types the same way regardless of whether they're fully monomorphized or not. Previously we had to distinguish between the two cases manually by choosing either SomeConstant or SomeConstantPoly when defining a builtin and now things are just consistent.

Copy link
Contributor

Choose a reason for hiding this comment

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

s/monomorphized/normalized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No:

  1. we had to distinguish based on monomorphization happening or not, that's what my comment is about
  2. this type appears normalized only because ElaborateBuiltin essentially performs normalization for built-in types. Any non built-in type would not be normalized. Again, we don't have TyLamRep currently, but it's trivial to add it and then we could apply it using TyAppRep and that wouldn't get normalized

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 had to distinguish based on monomorphization happening or not, that's what my comment is about

Well, we actually still have to, just in a different place. Writing a note.

@effectfully
Copy link
Contributor Author

This is another attempt at better API for polymorphic built-in functions over polymorphic built-in types. Based on #4220, but is more powerful and a lot simpler. I believe it's even simpler than what's in master, even though the new machinery is way more expressive.

I think this concludes the API changes that I wanted to happen, now the interface for defining built-in functions should be stable (but the internals will change drastically if we're lucky).

I'll be thinking how to explain builtins without committing too much to a particular representation of the internals.

Ready for review.

@effectfully effectfully requested review from michaelpj and kwxm January 7, 2022 20:05
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.

Superficial comments, I can't really review the details!

type GetName :: GHC.Type -> Nat -> Symbol
type family GetName k i where
GetName GHC.Type i = Lookup i '["a", "b", "c", "d", "e", "i", "j", "k", "l"]
GetName _ i = Lookup i '["f", "g", "h", "m", "n"]
Copy link
Contributor

Choose a reason for hiding this comment

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

worth a comment. This is intended for higher-kinded things, I assume.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup.

So instead of mixing up types whose values are actually unliftable with types that are only used
for type checking, we keep the distinction explicit.

The barrier between Haskell and Plutus is the barrier between the Type and the Rep contexts and
Copy link
Contributor

Choose a reason for hiding this comment

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

What if we view this through the lens we've talked about for the formalization: i.e. this distinction is rather one of kinds.

I'm not sure I've worked out how we might do it, but could we end up with something like this, where the user would write:

id :: forall (a :: ArbitraryType) . a -> a
idList :: forall (a :: BuiltinType) . [a] -> [a]

and then that works out? I know we don't have this distinction on the PLC side, but maybe we could have it here. Probably the devil is in the details, I don't know how we would implement that...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

idList :: forall (a :: BuiltinType) . [a] -> [a]

We can't have that, I'll add a note.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also [] has kind * -> *.


The barrier between Haskell and Plutus is the barrier between the Type and the Rep contexts and
that barrier must always be some explicit type constructor that switches the context from Type to
Rep. We've only considered 'Opaque' as an example of such type constructor, but we also have
Copy link
Contributor

Choose a reason for hiding this comment

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

Opaque :: BuiltinType -> ArbitraryType?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opaque works in the opposite direction! It takes a representation of a Plutus type (so it may have type-level lambdas for example, although we don't provide them currently, but we provide TyForallRep, which is very similar) and constructs a liftable/unliftable type out of that. And in most cases Opaque is indexed by a type representing a Plutus type variable, so it's not about built-in types at all.

(fun (con integer) (fun [ (con list) (con data) ] (con data)))
Copy link
Contributor

Choose a reason for hiding this comment

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

s/monomorphized/normalized?

@effectfully
Copy link
Contributor Author

Comments addressed, make sure to read another scary Note (as if we didn't have enough of them).

@kwxm
Copy link
Contributor

kwxm commented Jan 11, 2022

the new machinery is way more expressive.

Eek! Can you give some idea of how much more expressive it is? I'm worrying about specification here, and also maybe costing. In the specification I'm not trying to explain what's going on here, but rather what sort of things you're allowed to write, and with a generic description of the semantics of possible built-in functions and types. That's already quite difficult and it might be extremely hard to specify what's going on here in full generality. For example, I think you said that we could already implement GADTs if we wanted to, and as far as I can tell from Googling it's quite challenging to say what the semantics of those are.

I suppose that there will be many things be that we might not want to allow as builtins for all kinds of reasons, like costing. For example, we can't allow map because the cost of that will depend on the cost of the function it's mapping and then we'd need some kind of higher-order costing mechanism, which would be tricky at best. Maybe the specification can specify some conservative subset of the things we could actually implement, and we'd just require people not to do anything too fancy.

Copy link
Contributor

@kwxm kwxm left a comment

Choose a reason for hiding this comment

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

I don't understand the details, but I'm willing to believe that it all works. The code does look quite a bit neater in places, at least from the point of view of someone who might want to use this machinery rather than maintain it.

(all f (fun (type) (type)) (fun (all b (type) [ f b ]) (all b (type) [ f b ])))
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess that there will have been an a here that's disappeared during normalisation or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It just got renamed to b. Previously we'd provide all the names manually, but now they get generated automatically and I didn't care enough to make the generated names look good in the higher-kinded case, 'cause we don't have that in the default builtins.

Comment on lines -247 to +260
-> SomeConstantPoly uni (,) '[a, b]
-> SomeConstant uni (a, b)
Copy link
Contributor

Choose a reason for hiding this comment

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

The rest of the file does look quite a bit more readable.

type GetName i = Lookup i '["a", "b", "c", "d", "e", "f", "g", "h"]
type GetName :: GHC.Type -> Nat -> Symbol
type family GetName k i where
GetName GHC.Type i = Lookup i '["a", "b", "c", "d", "e", "i", "j", "k", "l"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the limited length of these lists imply a limit on the complexity of the types we can have, or is this just a cosmetic thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does the limited length of these lists imply a limit on the complexity of the types we can have

Yep, but if you add a new builtin with 10 type variables and get a type error because of that, you can always extend the list of names. I just thought it would be unlikely we'd need a builtin with more than 9 type variables.

One non-solution would be to instantiate @a@, then recurse on the type, construct a new function
that defers to the original @nullList@ but wraps its argument in a specific way (more on that below)
making it possible to assign a 'TypeScheme' to the resulting function. Astonishingly enough, that
could actually work and if we ever write a paper on builtins, we should mention that example, but:
Copy link
Contributor

Choose a reason for hiding this comment

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

s/paper/book/

Copy link
Contributor

Choose a reason for hiding this comment

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

(I'm joking, I hope).

@michaelpj
Copy link
Contributor

Eek! Can you give some idea of how much more expressive it is? I'm worrying about specification here, and also maybe costing.

I believe the machinery in question is just the machinery that works out how to turn the types of builtin implementation into TypeSchemes. So it shouldn't affect the implementation or the specification, it just makes it nicer to write things.

@effectfully
Copy link
Contributor Author

I believe the machinery in question is just the machinery that works out how to turn the types of builtin implementation into TypeSchemes.

Yes, that's correct, sorry about the ambiguity. By "expressiveness" I meant the expressiveness of the TypeScheme inference machinery, as in "the inference machinery is now more extensible and can look deeper into types, thus it's able to infer more". Nothing about what kinds of builtins can be expressed has changed.

@kwxm

rather what sort of things you're allowed to write, and with a generic description of the semantics of possible built-in functions and types.

I'm gonna be documenting something along these lines next.

For example, I think you said that we could already implement GADTs if we wanted to, and as far as I can tell from Googling it's quite challenging to say what the semantics of those are.

Yeah, I meant that we can express GADTs in Plutus Core (it's easy to do that, but compiling from actual Haskell GADTs may or may not be a nearly unsolvable problem), I've never pondered if we could express GADTs via the builtins machinery, maybe we could, dunno.

I suppose that there will be many things be that we might not want to allow as builtins for all kinds of reasons, like costing. For example, we can't allow map because the cost of that will depend on the cost of the function it's mapping and then we'd need some kind of higher-order costing mechanism, which would be tricky at best.

In theory we could allow a flavor of map that takes a function and a list and returns an iterated application of MkCons where each argument is a function applied to an element of the list. Then the cost for that is linear, because it takes linear time to construct that iterated application and the actual evaluation will happen outside of the builtins machinery, so it'll be costed properly there. I see your point, though.

In any case currently you can't apply a function to an argument within the builtins machinery. I'm gonna play with that in future though, but I'll preserve the invariant that we only need first-order costing.

@effectfully effectfully merged commit 808f68e into master Jan 11, 2022
@effectfully effectfully deleted the effectfully/disentangle-KnownTypeAst-from-KnownTypeIn branch January 11, 2022 15:01
MaximilianAlgehed pushed a commit to Quviq/plutus that referenced this pull request Mar 3, 2022
…O#4312)

* [Builtins] Disentangle 'KnownTypeAst' from 'KnownTypeIn'
* See Note [Unlifting values of built-in types]

This generalized the `TypeScheme` inference machinery and makes it more powerful and at the same time easier to use.
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.

4 participants