Skip to content

Conversation

@ana-pantilie
Copy link
Contributor

@ana-pantilie ana-pantilie commented Nov 19, 2025

@ana-pantilie

This comment was marked as outdated.

@ana-pantilie

This comment was marked as outdated.

@ana-pantilie ana-pantilie changed the title Value costing: insertCoin, unionValue Value costing: insertCoin, unionValue, scaleValue Nov 20, 2025
@ana-pantilie

This comment was marked as outdated.

@ana-pantilie ana-pantilie force-pushed the ana/value-costing-final branch 3 times, most recently from 1e44958 to abdc6ed Compare December 5, 2025 14:15
Copy link
Member

@zliu41 zliu41 left a 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.

Copy link
Member

@zliu41 zliu41 left a 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.

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.

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.

unValueDataModel <- linearInX ("UnValueData")

# Y wrapped with `TotalSize` (contained value size)
scaleValueModel <- linearInY ("ScaleValue")
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 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.

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'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).

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.

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
Copy link
Contributor

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.

@kwxm kwxm added Builtins Costing Anything relating to costs, fees, gas, etc. labels Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Builtins Costing Anything relating to costs, fees, gas, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants