-
Notifications
You must be signed in to change notification settings - Fork 502
Value costing: insertCoin, unionValue, scaleValue #7435
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
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
1e44958 to
abdc6ed
Compare
plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostingFun/SimpleJSON.hs
Outdated
Show resolved
Hide resolved
plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs
Outdated
Show resolved
Hide resolved
plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs
Outdated
Show resolved
Hide resolved
plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs
Outdated
Show resolved
Hide resolved
plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs
Outdated
Show resolved
Hide resolved
zliu41
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Value builtins should now be added to PlutusLedgerApi.Common.Versions.
plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs
Outdated
Show resolved
Hide resolved
plutus-core/cost-model/create-cost-model/BuiltinMemoryModels.hs
Outdated
Show resolved
Hide resolved
zliu41
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good but we need @kwxm to sign off on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some initial comments; I'll continue to review the PR (in particular, the benchmarking code: it's going to take me a while to grasp the details of that) and add more comments later. It all looks pretty sensible so far though.
plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostingFun/Core.hs
Outdated
Show resolved
Hide resolved
plutus-core/plutus-core/src/PlutusCore/Evaluation/Machine/CostingFun/Core.hs
Outdated
Show resolved
Hide resolved
| unValueDataModel <- linearInX ("UnValueData") | ||
|
|
||
| # Y wrapped with `TotalSize` (contained value size) | ||
| scaleValueModel <- linearInY ("ScaleValue") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still puzzled by the shape of the data here, but making it linear in y does give a good overapproximation for all values of y. The downward bend at the start drags the regression line down quite a bit and you end up with a negavie intercept, but later that gets adjusted to 1000 and we end up with a line that lies just above all of the benchmark times.
kwxm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added some more comments. I still need to check the benchmarking code though (not that I expect any problems, since the benchmark results look quite reasonable).
kwxm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks pretty much OK. I've added quite a lot of minor comments, and I think the memory cost for scaleValue needs to be updated.
| ---------------------------------------------------------------------------------------------------- | ||
| -- ScaleValue -------------------------------------------------------------------------------------- | ||
|
|
||
| scaleValueBenchmark :: StdGen -> Benchmark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd still like to work oout why the graph is that odd shape (curved at first but then straightening out). The benchmark inputs look perfectly reasonable, so it's a bit mystifying. I don't think we need to let that hold us up though.
Fixes https://github.com/IntersectMBO/plutus-private/issues/1899
Fixes https://github.com/IntersectMBO/plutus-private/issues/1900
Fixes https://github.com/IntersectMBO/plutus-private/issues/2004
See https://plutus.cardano.intersectmbo.org/pr-preview/cost-models/pr-7435/ for cost model vizualizations