cadence icon indicating copy to clipboard operation
cadence copied to clipboard

CBF Codec

Open robert-e-davidson3 opened this issue 2 years ago • 2 comments

Closes #1715 Closes https://github.com/onflow/cadence/issues/1941

Description

Encode cadence.Value and cadence.Type using custom binary codec.

Full test coverage is to be handled in a separate issue: https://github.com/onflow/cadence/issues/1939


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

robert-e-davidson3 avatar Aug 23 '22 02:08 robert-e-davidson3

Cadence Benchstat comparison

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

Collapsed results for better readability

old.txtnew.txt
time/opdelta
CheckContractInterfaceFungibleTokenConformance-2138µs ± 3%142µs ± 5%~(p=0.383 n=7+7)
ContractInterfaceFungibleToken-241.5µs ± 4%41.8µs ± 2%~(p=0.836 n=6+7)
InterpretRecursionFib-22.84ms ± 2%2.82ms ± 1%~(p=0.485 n=6+6)
NewInterpreter/new_interpreter-21.18µs ± 3%1.18µs ± 3%~(p=1.000 n=7+7)
NewInterpreter/new_sub-interpreter-2665ns ± 1%674ns ± 3%+1.38%(p=0.041 n=6+6)
ParseArray-28.82ms ± 3%8.80ms ± 3%~(p=1.000 n=6+6)
ParseDeploy/byte_array-213.6ms ± 3%13.6ms ± 5%~(p=1.000 n=7+7)
ParseDeploy/decode_hex-21.17ms ± 6%1.16ms ± 1%~(p=0.836 n=7+6)
ParseFungibleToken/With_memory_metering-2215µs ± 2%213µs ± 2%~(p=0.445 n=7+6)
ParseFungibleToken/Without_memory_metering-2166µs ± 2%166µs ± 2%~(p=0.805 n=7+7)
ParseInfix-27.87µs ± 2%7.94µs ± 3%~(p=0.365 n=7+7)
QualifiedIdentifierCreation/One_level-22.35ns ± 0%2.35ns ± 0%~(p=0.233 n=6+7)
QualifiedIdentifierCreation/Three_levels-2141ns ± 4%141ns ± 1%~(p=0.535 n=7+7)
RuntimeFungibleTokenTransfer-2755µs ± 6%549µs ± 4%−27.23%(p=0.001 n=6+7)
RuntimeResourceDictionaryValues-25.35ms ± 6%5.35ms ± 5%~(p=0.620 n=7+7)
RuntimeScriptNoop-219.6µs ±24%15.2µs ± 3%~(p=0.097 n=7+7)
ValueIsSubtypeOfSemaType-289.9ns ± 5%88.6ns ± 1%~(p=0.295 n=7+6)
 
alloc/opdelta
CheckContractInterfaceFungibleTokenConformance-261.5kB ± 0%61.5kB ± 0%~(p=0.592 n=7+7)
ContractInterfaceFungibleToken-223.9kB ± 0%23.9kB ± 0%~(p=1.000 n=7+7)
InterpretRecursionFib-21.23MB ± 0%1.23MB ± 0%~(p=0.409 n=7+7)
NewInterpreter/new_interpreter-2848B ± 0%848B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-2264B ± 0%264B ± 0%~(all equal)
ParseArray-22.79MB ± 2%2.77MB ± 0%~(p=0.867 n=7+6)
ParseDeploy/byte_array-24.47MB ± 3%4.45MB ± 3%~(p=0.779 n=7+7)
ParseDeploy/decode_hex-2214kB ± 0%214kB ± 0%~(p=0.343 n=7+7)
ParseFungibleToken/With_memory_metering-236.3kB ± 0%36.3kB ± 0%~(p=0.837 n=7+7)
ParseFungibleToken/Without_memory_metering-236.3kB ± 0%36.3kB ± 0%~(p=0.152 n=7+7)
ParseInfix-22.17kB ± 0%2.17kB ± 0%~(p=0.449 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
RuntimeFungibleTokenTransfer-2111kB ± 1%110kB ± 0%−0.90%(p=0.011 n=7+7)
RuntimeResourceDictionaryValues-22.27MB ± 0%2.27MB ± 0%~(p=0.456 n=7+7)
RuntimeScriptNoop-28.65kB ± 1%8.65kB ± 0%~(p=0.710 n=7+7)
ValueIsSubtypeOfSemaType-248.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
CheckContractInterfaceFungibleTokenConformance-21.03k ± 0%1.03k ± 0%~(all equal)
ContractInterfaceFungibleToken-2426 ± 0%426 ± 0%~(all equal)
InterpretRecursionFib-222.5k ± 0%22.5k ± 0%~(all equal)
NewInterpreter/new_interpreter-214.0 ± 0%14.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-25.00 ± 0%5.00 ± 0%~(all equal)
ParseArray-270.0k ± 0%70.0k ± 0%~(p=1.000 n=7+7)
ParseDeploy/byte_array-2105k ± 0%105k ± 0%~(p=1.000 n=7+7)
ParseDeploy/decode_hex-277.0 ± 0%77.0 ± 0%~(all equal)
ParseFungibleToken/With_memory_metering-21.06k ± 0%1.06k ± 0%~(all equal)
ParseFungibleToken/Without_memory_metering-21.06k ± 0%1.06k ± 0%~(all equal)
ParseInfix-266.0 ± 0%66.0 ± 0%~(all equal)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
RuntimeFungibleTokenTransfer-22.20k ± 0%2.20k ± 0%~(all equal)
RuntimeResourceDictionaryValues-236.9k ± 0%36.9k ± 0%~(p=0.091 n=5+7)
RuntimeScriptNoop-2143 ± 0%143 ± 0%~(all equal)
ValueIsSubtypeOfSemaType-21.00 ± 0%1.00 ± 0%~(all equal)
 

github-actions[bot] avatar Aug 23 '22 02:08 github-actions[bot]

Codecov Report

Merging #1905 (be13c44) into feature/external-cadence-encoding (377e36c) will increase coverage by 1.12%. The diff coverage is 79.23%.

@@                          Coverage Diff                          @@
##           feature/external-cadence-encoding    #1905      +/-   ##
=====================================================================
+ Coverage                              77.23%   78.35%   +1.12%     
=====================================================================
  Files                                    308      349      +41     
  Lines                                  63841    65242    +1401     
=====================================================================
+ Hits                                   49305    51119    +1814     
+ Misses                                 12631    12272     -359     
+ Partials                                1905     1851      -54     
Flag Coverage Δ
unittests 78.35% <79.23%> (+1.12%) :arrow_up:

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

Impacted Files Coverage Δ
runtime/interpreter/decode.go 46.92% <ø> (ø)
types.go 97.59% <ø> (+6.76%) :arrow_up:
values.go 72.70% <ø> (+6.19%) :arrow_up:
encoding/cbf/cbf_codec/function_type.go 40.00% <40.00%> (ø)
encoding/cbf/cbf_codec/restricted_type.go 40.00% <40.00%> (ø)
encoding/cbf/cbf_codec/optional_type.go 47.05% <47.05%> (ø)
encoding/cbf/cbf_codec/reference_type.go 47.05% <47.05%> (ø)
encoding/cbf/cbf_codec/interface_type.go 50.00% <50.00%> (ø)
encoding/cbf/common_codec/address.go 53.33% <53.33%> (ø)
encoding/cbf/cbf_codec/bool.go 57.14% <57.14%> (ø)
... and 50 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Sep 08 '22 23:09 codecov[bot]

Closing in favor of redesigned solution captured in: https://github.com/onflow/cadence/issues/2157

j1010001 avatar Nov 22 '22 18:11 j1010001