IntersectMBO / IntersectMBO/plutus
`unionValue` and `unValueData` are CPU-quadratic contrary to their Haddocks
- Dominant language
- Haskell
- Stars
- 1.6k
- Forks
- 508
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 22
Description
The Haddocks of
```haskell
{-| \(O(n_{1}) + O(n_{2})\), where \(n_{1}\) and \(n_{2}\) are the total sizes
(i.e., sum of inner map sizes) of the two maps.
Shortcircuits if either value is empty.
Since 'unionValue' is commutative, we switch the arguments whenever the second
value is larger in total size than the first one. We have found through experimentation
that this results in better performance in practice. -}
unionValue :: Value -> Value -> BuiltinResult Value
{-| \(O(n)\). Decodes `Data` into `Value`.
This is the denotation of @UnValueData@ in Plutus V1, V2 and V3. -}
unValueData :: Data -> BuiltinResult Value
```
do not agree with what's in `builtinCostModelC.json`:
```json
"unValueData": {
"cpu": {
"arguments": {
"c0": 1000,
"c1": 95933,
"c2": 1
},
"type": "quadratic_in_x"
},
"memory": <...>
},
"unionValue": {
"cpu": {
"arguments": {
"c00": 1000,
"c01": 183150,
"c10": 172116,
"c11": 6
},
"type": "with_interaction_in_x_and_y"
},
"memory": <...>
}
```
where the worker of `"with_interaction_in_x_and_y"` is
```haskell
evaluateTwoVariableWithInteractionFunction
:: TwoVariableWithInteractionFunction
-> CostingInteger
-> CostingInteger
-> CostingInteger
evaluateTwoVariableWithInteractionFunction
( TwoVariableWithInteractionFunction
(Coefficient00 c00)
(Coefficient10 c10)
(Coefficient01 c01)
(Coefficient11 c11)
)
x
y =
c10 * x + c01 * y + c11 * (x * y) + c00
```
Contributor guide
Assessment
This issue has not been assessed yet.