cadence
cadence copied to clipboard
codec cadence.value cadence.type
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
Codecov Report
Merging #1856 (bb8b4de) into feature/external-cadence-encoding (aac9ecc) will decrease coverage by
0.08%
. The diff coverage is64.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.
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.txt | new.txt | |||
---|---|---|---|---|
time/op | delta | |||
CheckContractInterfaceFungibleTokenConformance-2 | 137µs ± 2% | 136µs ± 2% | ~ | (p=0.710 n=7+7) |
ContractInterfaceFungibleToken-2 | 40.3µs ± 1% | 40.8µs ± 2% | +1.44% | (p=0.009 n=6+6) |
InterpretRecursionFib-2 | 3.46ms ± 1% | 3.44ms ± 0% | −0.57% | (p=0.009 n=6+6) |
NewInterpreter/new_interpreter-2 | 1.15µs ± 0% | 1.15µs ± 0% | ~ | (p=0.883 n=6+6) |
NewInterpreter/new_sub-interpreter-2 | 2.40µs ± 1% | 2.45µs ± 4% | ~ | (p=0.128 n=6+7) |
ParseArray-2 | 8.55ms ± 1% | 8.58ms ± 0% | ~ | (p=0.268 n=7+5) |
ParseDeploy/byte_array-2 | 13.1ms ± 1% | 13.0ms ± 1% | ~ | (p=0.485 n=6+6) |
ParseDeploy/decode_hex-2 | 1.14ms ± 2% | 1.14ms ± 2% | ~ | (p=0.534 n=6+7) |
ParseFungibleToken/With_memory_metering-2 | 207µs ± 1% | 208µs ± 3% | ~ | (p=0.836 n=6+7) |
ParseFungibleToken/Without_memory_metering-2 | 161µs ± 4% | 159µs ± 1% | ~ | (p=0.628 n=7+6) |
ParseInfix-2 | 7.73µs ± 1% | 7.84µs ± 4% | ~ | (p=0.976 n=7+7) |
QualifiedIdentifierCreation/One_level-2 | 2.68ns ± 0% | 2.68ns ± 0% | ~ | (p=0.538 n=7+7) |
QualifiedIdentifierCreation/Three_levels-2 | 143ns ± 2% | 142ns ± 0% | ~ | (p=0.076 n=7+6) |
RuntimeFungibleTokenTransfer-2 | 1.24ms ±23% | 1.27ms ±24% | ~ | (p=0.456 n=7+7) |
RuntimeResourceDictionaryValues-2 | 6.66ms ± 2% | 6.60ms ± 3% | ~ | (p=0.620 n=7+7) |
ValueIsSubtypeOfSemaType-2 | 88.3ns ± 1% | 88.1ns ± 0% | ~ | (p=0.507 n=7+6) |
alloc/op | delta | |||
CheckContractInterfaceFungibleTokenConformance-2 | 63.6kB ± 0% | 63.6kB ± 0% | ~ | (p=0.245 n=6+7) |
ContractInterfaceFungibleToken-2 | 25.1kB ± 0% | 25.1kB ± 0% | ~ | (p=1.000 n=7+7) |
InterpretRecursionFib-2 | 1.51MB ± 0% | 1.51MB ± 0% | ~ | (p=0.984 n=7+7) |
NewInterpreter/new_interpreter-2 | 928B ± 0% | 928B ± 0% | ~ | (all equal) |
NewInterpreter/new_sub-interpreter-2 | 1.46kB ± 0% | 1.46kB ± 0% | ~ | (all equal) |
ParseArray-2 | 2.80MB ± 2% | 2.80MB ± 2% | ~ | (p=0.902 n=7+7) |
ParseDeploy/byte_array-2 | 4.42MB ± 3% | 4.44MB ± 3% | ~ | (p=0.686 n=7+7) |
ParseDeploy/decode_hex-2 | 214kB ± 0% | 214kB ± 0% | ~ | (p=0.614 n=7+7) |
ParseFungibleToken/With_memory_metering-2 | 36.3kB ± 0% | 36.3kB ± 0% | ~ | (p=0.853 n=7+7) |
ParseFungibleToken/Without_memory_metering-2 | 36.3kB ± 0% | 36.3kB ± 0% | ~ | (p=0.203 n=7+7) |
ParseInfix-2 | 2.17kB ± 0% | 2.17kB ± 0% | ~ | (p=0.883 n=7+7) |
QualifiedIdentifierCreation/One_level-2 | 0.00B | 0.00B | ~ | (all equal) |
QualifiedIdentifierCreation/Three_levels-2 | 64.0B ± 0% | 64.0B ± 0% | ~ | (all equal) |
RuntimeFungibleTokenTransfer-2 | 229kB ± 0% | 229kB ± 1% | ~ | (p=0.902 n=7+7) |
RuntimeResourceDictionaryValues-2 | 2.25MB ± 0% | 2.25MB ± 0% | ~ | (p=0.534 n=7+6) |
ValueIsSubtypeOfSemaType-2 | 48.0B ± 0% | 48.0B ± 0% | ~ | (all equal) |
allocs/op | delta | |||
CheckContractInterfaceFungibleTokenConformance-2 | 1.05k ± 0% | 1.05k ± 0% | ~ | (all equal) |
ContractInterfaceFungibleToken-2 | 441 ± 0% | 441 ± 0% | ~ | (all equal) |
InterpretRecursionFib-2 | 33.5k ± 0% | 33.5k ± 0% | ~ | (all equal) |
NewInterpreter/new_interpreter-2 | 13.0 ± 0% | 13.0 ± 0% | ~ | (all equal) |
NewInterpreter/new_sub-interpreter-2 | 42.0 ± 0% | 42.0 ± 0% | ~ | (all equal) |
ParseArray-2 | 70.0k ± 0% | 70.0k ± 0% | ~ | (p=0.538 n=6+7) |
ParseDeploy/byte_array-2 | 105k ± 0% | 105k ± 0% | ~ | (p=0.385 n=6+7) |
ParseDeploy/decode_hex-2 | 77.0 ± 0% | 77.0 ± 0% | ~ | (all equal) |
ParseFungibleToken/With_memory_metering-2 | 1.06k ± 0% | 1.06k ± 0% | ~ | (all equal) |
ParseFungibleToken/Without_memory_metering-2 | 1.06k ± 0% | 1.06k ± 0% | ~ | (all equal) |
ParseInfix-2 | 66.0 ± 0% | 66.0 ± 0% | ~ | (all equal) |
QualifiedIdentifierCreation/One_level-2 | 0.00 | 0.00 | ~ | (all equal) |
QualifiedIdentifierCreation/Three_levels-2 | 2.00 ± 0% | 2.00 ± 0% | ~ | (all equal) |
RuntimeFungibleTokenTransfer-2 | 4.16k ± 0% | 4.16k ± 0% | ~ | (p=1.000 n=7+7) |
RuntimeResourceDictionaryValues-2 | 37.5k ± 0% | 37.5k ± 0% | ~ | (p=0.767 n=7+6) |
ValueIsSubtypeOfSemaType-2 | 1.00 ± 0% | 1.00 ± 0% | ~ | (all equal) |