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

cadence.Value.Type method back to original param list #1633

Conversation

robert-e-davidson3
Copy link
Contributor

@robert-e-davidson3 robert-e-davidson3 commented May 6, 2022

Closes https://github.com/dapperlabs/cadence-private-issues/issues/46

Description

The SDK etc use the cadence.Value and cadence.Type types. This PR undoes a change to the cadence.Value.Type method so the API will remain unchanged in the next Cadence release.

The cadence.Value.MeteredType method was added for when memory metering is needed.

Another change: I added compile-time interface type checking for the cadence.Value types. ex: var _ Value = Void{}.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov
Copy link

codecov bot commented May 6, 2022

Codecov Report

Merging #1633 (917e839) into feature/memory-metering (7cb1f67) will decrease coverage by 0.26%.
The diff coverage is 47.39%.

@@                     Coverage Diff                     @@
##           feature/memory-metering    #1633      +/-   ##
===========================================================
- Coverage                    76.62%   76.36%   -0.27%     
===========================================================
  Files                          291      291              
  Lines                        60092    60452     +360     
===========================================================
+ Hits                         46046    46163     +117     
- Misses                       12439    12678     +239     
- Partials                      1607     1611       +4     
Flag Coverage Δ
unittests 76.36% <47.39%> (-0.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
runtime/convertTypes.go 61.50% <29.68%> (-14.90%) ⬇️
values.go 65.90% <34.11%> (-6.56%) ⬇️
encoding/json/decode.go 77.54% <41.02%> (+0.02%) ⬆️
types.go 78.20% <74.05%> (-1.52%) ⬇️
runtime/convertValues.go 78.18% <100.00%> (ø)
runtime/literal.go 86.29% <100.00%> (ø)
runtime/runtime.go 86.40% <100.00%> (ø)
runtime/sema/simple_type.go 92.30% <0.00%> (-3.85%) ⬇️
runtime/sema/check_unary_expression.go 91.22% <0.00%> (-0.30%) ⬇️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7cb1f67...917e839. Read the comment docs.

@github-actions
Copy link

github-actions bot commented May 6, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:feature/memory-metering commit 33cd9e0
The command for i in {1..N}; do go test ./... -run=XXX -bench=. -shuffle=on; done was used.
Bench tests were run a total of 7 times on each branch.

Results

old.txtnew.txt
time/opdelta
RuntimeFungibleTokenTransfer-21.52ms ±22%1.46ms ±30%~(p=0.805 n=7+7)
RuntimeResourceDictionaryValues-27.91ms ± 4%7.93ms ± 1%~(p=0.383 n=7+7)
Transfer-2100ns ± 2%99ns ± 3%~(p=0.272 n=7+7)
ParseArray-216.6ms ± 9%15.6ms ± 2%~(p=0.234 n=7+6)
ParseFungibleToken/Without_memory_metering-2252µs ± 1%251µs ± 1%~(p=0.937 n=6+6)
ParseFungibleToken/With_memory_metering-2309µs ± 2%309µs ± 3%~(p=0.836 n=6+7)
ParseDeploy/byte_array-224.6ms ± 4%24.5ms ± 3%~(p=1.000 n=6+6)
ParseDeploy/decode_hex-21.42ms ± 2%1.42ms ± 3%~(p=0.902 n=7+7)
ParseInfix-211.0µs ± 1%11.1µs ± 8%~(p=0.710 n=7+7)
QualifiedIdentifierCreation/One_level-23.31ns ± 3%3.31ns ± 4%~(p=0.874 n=7+7)
QualifiedIdentifierCreation/Three_levels-2170ns ± 1%170ns ± 1%~(p=0.469 n=6+7)
ContractInterfaceFungibleToken-248.5µs ± 1%48.3µs ± 1%~(p=0.310 n=6+6)
CheckContractInterfaceFungibleTokenConformance-2173µs ± 4%173µs ± 2%~(p=0.805 n=7+7)
NewInterpreter/new_interpreter-21.35µs ± 2%1.36µs ± 4%~(p=0.710 n=7+7)
NewInterpreter/new_sub-interpreter-22.82µs ± 8%2.69µs ± 3%~(p=0.128 n=7+7)
InterpretRecursionFib-23.27ms ± 5%3.24ms ± 4%~(p=0.805 n=7+7)
 
alloc/opdelta
RuntimeFungibleTokenTransfer-2276kB ± 0%276kB ± 0%~(p=0.628 n=5+6)
RuntimeResourceDictionaryValues-22.25MB ± 0%2.25MB ± 0%~(p=0.181 n=7+6)
Transfer-248.0B ± 0%48.0B ± 0%~(all equal)
ParseFungibleToken/Without_memory_metering-2199kB ± 0%199kB ± 0%~(all equal)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.3kB ± 0%66.3kB ± 0%~(all equal)
NewInterpreter/new_interpreter-2888B ± 0%888B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.40kB ± 0%1.40kB ± 0%~(all equal)
InterpretRecursionFib-21.25MB ± 0%1.25MB ± 0%~(p=0.284 n=7+7)
ParseFungibleToken/With_memory_metering-2199kB ± 0%199kB ± 0%−0.00%(p=0.042 n=7+6)
ContractInterfaceFungibleToken-226.7kB ± 0%26.7kB ± 0%−0.00%(p=0.042 n=7+6)
 
allocs/opdelta
RuntimeFungibleTokenTransfer-24.59k ± 0%4.59k ± 0%~(p=0.697 n=7+6)
RuntimeResourceDictionaryValues-237.6k ± 0%37.6k ± 0%~(p=0.274 n=7+7)
Transfer-21.00 ± 0%1.00 ± 0%~(all equal)
ParseFungibleToken/Without_memory_metering-21.07k ± 0%1.07k ± 0%~(all equal)
ParseFungibleToken/With_memory_metering-21.07k ± 0%1.07k ± 0%~(all equal)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
ContractInterfaceFungibleToken-2460 ± 0%460 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-241.0 ± 0%41.0 ± 0%~(all equal)
InterpretRecursionFib-223.8k ± 0%23.8k ± 0%~(all equal)
 

Copy link
Member

@SupunS SupunS 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!

Copy link
Member

@SupunS SupunS left a comment

Choose a reason for hiding this comment

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

Thanks for adding these!

@robert-e-davidson3 robert-e-davidson3 merged commit 24d36f1 into feature/memory-metering May 7, 2022
@SupunS SupunS deleted the robert/Cadence-value-Type-method-should-be-split-into-metered-unmetered-46 branch May 9, 2022 15:51
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.

2 participants