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] No-legacy unlifting #4510

Closed
wants to merge 11 commits into from

Conversation

effectfully
Copy link
Contributor

Don't look here yet.

@effectfully
Copy link
Contributor Author

/benchmark plutus-benchmark:validation

@iohk-devops
Copy link

Comparing benchmark results of 'plutus-benchmark:validation' on 'e59ade143' (base) and '5d3fb5abe' (PR)

Script e59ade1 5d3fb5a Change
auction_1-1 227.3 μs 204.7 μs -9.9%
auction_1-2 862.7 μs 826.0 μs -4.3%
auction_1-3 853.1 μs 815.2 μs -4.4%
auction_1-4 295.2 μs 260.1 μs -11.9%
auction_2-1 228.2 μs 204.9 μs -10.2%
auction_2-2 861.7 μs 825.1 μs -4.2%
auction_2-3 1.091 ms 1.048 ms -3.9%
auction_2-4 850.4 μs 810.9 μs -4.6%
auction_2-5 293.6 μs 259.7 μs -11.5%
crowdfunding-success-1 267.1 μs 239.8 μs -10.2%
crowdfunding-success-2 266.9 μs 239.5 μs -10.3%
crowdfunding-success-3 266.6 μs 240.2 μs -9.9%
currency-1 321.0 μs 302.6 μs -5.7%
escrow-redeem_1-1 464.2 μs 431.1 μs -7.1%
escrow-redeem_1-2 463.3 μs 431.4 μs -6.9%
escrow-redeem_2-1 544.3 μs 505.2 μs -7.2%
escrow-redeem_2-2 545.3 μs 505.9 μs -7.2%
escrow-redeem_2-3 545.0 μs 505.4 μs -7.3%
escrow-refund-1 200.4 μs 181.8 μs -9.3%
future-increase-margin-1 321.2 μs 302.7 μs -5.8%
future-increase-margin-2 724.1 μs 689.3 μs -4.8%
future-increase-margin-3 725.4 μs 683.2 μs -5.8%
future-increase-margin-4 679.0 μs 637.5 μs -6.1%
future-increase-margin-5 1.059 ms 1.019 ms -3.8%
future-pay-out-1 322.3 μs 303.0 μs -6.0%
future-pay-out-2 725.2 μs 683.5 μs -5.8%
future-pay-out-3 724.5 μs 682.3 μs -5.8%
future-pay-out-4 1.054 ms 1.015 ms -3.7%
future-settle-early-1 322.2 μs 301.6 μs -6.4%
future-settle-early-2 723.8 μs 680.1 μs -6.0%
future-settle-early-3 724.6 μs 681.6 μs -5.9%
future-settle-early-4 807.5 μs 773.8 μs -4.2%
game-sm-success_1-1 524.2 μs 488.5 μs -6.8%
game-sm-success_1-2 249.2 μs 222.8 μs -10.6%
game-sm-success_1-3 848.2 μs 809.1 μs -4.6%
game-sm-success_1-4 289.7 μs 259.8 μs -10.3%
game-sm-success_2-1 525.5 μs 489.9 μs -6.8%
game-sm-success_2-2 250.4 μs 224.6 μs -10.3%
game-sm-success_2-3 846.2 μs 811.6 μs -4.1%
game-sm-success_2-4 290.1 μs 260.9 μs -10.1%
game-sm-success_2-5 850.3 μs 807.2 μs -5.1%
game-sm-success_2-6 289.7 μs 260.2 μs -10.2%
multisig-sm-1 538.1 μs 502.7 μs -6.6%
multisig-sm-2 527.1 μs 489.6 μs -7.1%
multisig-sm-3 532.2 μs 494.7 μs -7.0%
multisig-sm-4 538.7 μs 500.0 μs -7.2%
multisig-sm-5 752.5 μs 721.6 μs -4.1%
multisig-sm-6 535.9 μs 503.6 μs -6.0%
multisig-sm-7 525.0 μs 490.3 μs -6.6%
multisig-sm-8 530.5 μs 494.7 μs -6.7%
multisig-sm-9 536.2 μs 500.5 μs -6.7%
multisig-sm-10 753.5 μs 718.3 μs -4.7%
ping-pong-1 441.0 μs 412.1 μs -6.6%
ping-pong-2 440.0 μs 411.8 μs -6.4%
ping-pong_2-1 262.7 μs 242.7 μs -7.6%
prism-1 208.5 μs 184.7 μs -11.4%
prism-2 564.7 μs 529.1 μs -6.3%
prism-3 479.9 μs 445.1 μs -7.3%
pubkey-1 175.5 μs 157.0 μs -10.5%
stablecoin_1-1 1.179 ms 1.120 ms -5.0%
stablecoin_1-2 243.1 μs 217.6 μs -10.5%
stablecoin_1-3 1.348 ms 1.276 ms -5.3%
stablecoin_1-4 259.1 μs 232.4 μs -10.3%
stablecoin_1-5 1.694 ms 1.596 ms -5.8%
stablecoin_1-6 319.9 μs 287.6 μs -10.1%
stablecoin_2-1 1.175 ms 1.115 ms -5.1%
stablecoin_2-2 243.3 μs 216.4 μs -11.1%
stablecoin_2-3 1.340 ms 1.272 ms -5.1%
stablecoin_2-4 258.1 μs 231.9 μs -10.2%
token-account-1 242.6 μs 227.1 μs -6.4%
token-account-2 429.7 μs 401.6 μs -6.5%
uniswap-1 537.1 μs 511.9 μs -4.7%
uniswap-2 287.1 μs 264.9 μs -7.7%
uniswap-3 2.178 ms 2.044 ms -6.2%
uniswap-4 432.6 μs 380.1 μs -12.1%
uniswap-5 1.508 ms 1.407 ms -6.7%
uniswap-6 417.1 μs 368.8 μs -11.6%
vesting-1 462.8 μs 434.9 μs -6.0%

@effectfully
Copy link
Contributor Author

effectfully commented Mar 30, 2022

-7.18% on average.

@michaelpj ^ this is deferred unlifting done right and without support for immediate unlifting. The latter is going to slow down the former (don't know by how much at the moment). We may remedy that if instead of choosing the unlifting mode when constructing the BuiltinsRuntime we propagate that logic all the way into the CEK machine. Questions:

  1. is deferred unlifting with no support for immediate unlifting out of question? Does the current chain synchronize if we make unlifting deferred?
  2. what do you think about propagating the unlifting mode all the way into the CEK machine?

@michaelpj
Copy link
Contributor

what do you think about propagating the unlifting mode all the way into the CEK machine?

We'll definitely need to do this, since we need it to be configurable at runtime.

Comment on lines 567 to +572
spendBudgetCek (BBuiltinApp fun) cost
let !(errOrRes, logs) = makeKnownRun (Just term) x
let !(errOrRes, logs) = runEmitter $ runExceptT getX
?cekEmitter logs
case errOrRes of
Left err -> throwMakeKnownErrorWithCause err
Right res -> pure res
Left err -> throwReadKnownErrorWithCause $ term <$ err
Right x -> pure x
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note to self: this should be perfectly fine, but there's a subtlety here: the costing function kinda assumes that the arguments are of particular types, however an argument can be of the wrong type at runtime and the costing function will be applied to it and something will be computed. In the other PR an argument of the unexpected type is an evaluation error right away. It's probably fine to be a bit sloppy with how costing is managed in case of evaluation failure, but this needs to be documented and discussed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh no, it's all wrong. Ok, that's for tomorrow.

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, that is subtle: it fits into the world in which "real" builtins take typed constants and need to be costed appropriately (i.e. taking into account the cases where they're given ill-typed arguments). I think this all works out okay because the runtime-typechecking part is quick and happens first, but it is indeed another dark corner.

@effectfully
Copy link
Contributor Author

Closing in favor of #4516.

@effectfully effectfully closed this Apr 6, 2022
@effectfully effectfully deleted the effectfully/builtins/no-legacy-unlifting branch April 6, 2022 22:44
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