cadence icon indicating copy to clipboard operation
cadence copied to clipboard

codec cadence.value cadence.type

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

Progress towards https://github.com/onflow/cadence/issues/1715

Description

This is the first pass at encoding/decoding cadence.Value and cadence.Type in a performant format. This PR in particular emulates the same work done for the sema types. The sema codec is also affected because common code has been refactored out.


  • [ ] 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
  • [x] Updated relevant documentation
  • [x] Re-reviewed Files changed in the Github PR explorer
  • [x] Added appropriate labels

robert-e-davidson3 avatar Jul 29 '22 02:07 robert-e-davidson3

Codecov Report

Merging #1856 (bb8b4de) into feature/external-cadence-encoding (aac9ecc) will decrease coverage by 0.08%. The diff coverage is 64.37%.

@@                          Coverage Diff                          @@
##           feature/external-cadence-encoding    #1856      +/-   ##
=====================================================================
- Coverage                              77.31%   77.22%   -0.09%     
=====================================================================
  Files                                    296      299       +3     
  Lines                                  63667    63975     +308     
=====================================================================
+ Hits                                   49221    49406     +185     
- Misses                                 12560    12663     +103     
- Partials                                1886     1906      +20     
Flag Coverage Δ
unittests 77.22% <64.37%> (-0.09%) :arrow_down:

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

Impacted Files Coverage Δ
runtime/convertValues.go 79.94% <ø> (ø)
types.go 90.82% <ø> (+0.60%) :arrow_up:
encoding/custom/value_codec/encode.go 51.18% <51.18%> (ø)
encoding/custom/value_codec/decode.go 58.49% <58.49%> (ø)
encoding/custom/common_codec/common.go 89.36% <89.36%> (ø)
encoding/custom/sema_codec/encode.go 56.24% <90.47%> (-0.37%) :arrow_down:
encoding/custom/sema_codec/decode.go 62.05% <100.00%> (-0.19%) :arrow_down:

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 aac9ecc...bb8b4de. Read the comment docs.

codecov[bot] avatar Jul 29 '22 02:07 codecov[bot]

Cadence Benchstat comparison

This branch with compared with the base branch onflow:feature/external-cadence-encoding commit aac9eccefd392198b814d7cfa73987596fe73983 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-2137µs ± 2%136µs ± 2%~(p=0.710 n=7+7)
ContractInterfaceFungibleToken-240.3µs ± 1%40.8µs ± 2%+1.44%(p=0.009 n=6+6)
InterpretRecursionFib-23.46ms ± 1%3.44ms ± 0%−0.57%(p=0.009 n=6+6)
NewInterpreter/new_interpreter-21.15µs ± 0%1.15µs ± 0%~(p=0.883 n=6+6)
NewInterpreter/new_sub-interpreter-22.40µs ± 1%2.45µs ± 4%~(p=0.128 n=6+7)
ParseArray-28.55ms ± 1%8.58ms ± 0%~(p=0.268 n=7+5)
ParseDeploy/byte_array-213.1ms ± 1%13.0ms ± 1%~(p=0.485 n=6+6)
ParseDeploy/decode_hex-21.14ms ± 2%1.14ms ± 2%~(p=0.534 n=6+7)
ParseFungibleToken/With_memory_metering-2207µs ± 1%208µs ± 3%~(p=0.836 n=6+7)
ParseFungibleToken/Without_memory_metering-2161µs ± 4%159µs ± 1%~(p=0.628 n=7+6)
ParseInfix-27.73µs ± 1%7.84µs ± 4%~(p=0.976 n=7+7)
QualifiedIdentifierCreation/One_level-22.68ns ± 0%2.68ns ± 0%~(p=0.538 n=7+7)
QualifiedIdentifierCreation/Three_levels-2143ns ± 2%142ns ± 0%~(p=0.076 n=7+6)
RuntimeFungibleTokenTransfer-21.24ms ±23%1.27ms ±24%~(p=0.456 n=7+7)
RuntimeResourceDictionaryValues-26.66ms ± 2%6.60ms ± 3%~(p=0.620 n=7+7)
ValueIsSubtypeOfSemaType-288.3ns ± 1%88.1ns ± 0%~(p=0.507 n=7+6)
 
alloc/opdelta
CheckContractInterfaceFungibleTokenConformance-263.6kB ± 0%63.6kB ± 0%~(p=0.245 n=6+7)
ContractInterfaceFungibleToken-225.1kB ± 0%25.1kB ± 0%~(p=1.000 n=7+7)
InterpretRecursionFib-21.51MB ± 0%1.51MB ± 0%~(p=0.984 n=7+7)
NewInterpreter/new_interpreter-2928B ± 0%928B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.46kB ± 0%1.46kB ± 0%~(all equal)
ParseArray-22.80MB ± 2%2.80MB ± 2%~(p=0.902 n=7+7)
ParseDeploy/byte_array-24.42MB ± 3%4.44MB ± 3%~(p=0.686 n=7+7)
ParseDeploy/decode_hex-2214kB ± 0%214kB ± 0%~(p=0.614 n=7+7)
ParseFungibleToken/With_memory_metering-236.3kB ± 0%36.3kB ± 0%~(p=0.853 n=7+7)
ParseFungibleToken/Without_memory_metering-236.3kB ± 0%36.3kB ± 0%~(p=0.203 n=7+7)
ParseInfix-22.17kB ± 0%2.17kB ± 0%~(p=0.883 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
RuntimeFungibleTokenTransfer-2229kB ± 0%229kB ± 1%~(p=0.902 n=7+7)
RuntimeResourceDictionaryValues-22.25MB ± 0%2.25MB ± 0%~(p=0.534 n=7+6)
ValueIsSubtypeOfSemaType-248.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
CheckContractInterfaceFungibleTokenConformance-21.05k ± 0%1.05k ± 0%~(all equal)
ContractInterfaceFungibleToken-2441 ± 0%441 ± 0%~(all equal)
InterpretRecursionFib-233.5k ± 0%33.5k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-242.0 ± 0%42.0 ± 0%~(all equal)
ParseArray-270.0k ± 0%70.0k ± 0%~(p=0.538 n=6+7)
ParseDeploy/byte_array-2105k ± 0%105k ± 0%~(p=0.385 n=6+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-24.16k ± 0%4.16k ± 0%~(p=1.000 n=7+7)
RuntimeResourceDictionaryValues-237.5k ± 0%37.5k ± 0%~(p=0.767 n=7+6)
ValueIsSubtypeOfSemaType-21.00 ± 0%1.00 ± 0%~(all equal)
 

github-actions[bot] avatar Jul 29 '22 02:07 github-actions[bot]