cadence
cadence copied to clipboard
CBF Codec
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
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.txt | new.txt | |||
---|---|---|---|---|
time/op | delta | |||
CheckContractInterfaceFungibleTokenConformance-2 | 138µs ± 3% | 142µs ± 5% | ~ | (p=0.383 n=7+7) |
ContractInterfaceFungibleToken-2 | 41.5µs ± 4% | 41.8µs ± 2% | ~ | (p=0.836 n=6+7) |
InterpretRecursionFib-2 | 2.84ms ± 2% | 2.82ms ± 1% | ~ | (p=0.485 n=6+6) |
NewInterpreter/new_interpreter-2 | 1.18µs ± 3% | 1.18µs ± 3% | ~ | (p=1.000 n=7+7) |
NewInterpreter/new_sub-interpreter-2 | 665ns ± 1% | 674ns ± 3% | +1.38% | (p=0.041 n=6+6) |
ParseArray-2 | 8.82ms ± 3% | 8.80ms ± 3% | ~ | (p=1.000 n=6+6) |
ParseDeploy/byte_array-2 | 13.6ms ± 3% | 13.6ms ± 5% | ~ | (p=1.000 n=7+7) |
ParseDeploy/decode_hex-2 | 1.17ms ± 6% | 1.16ms ± 1% | ~ | (p=0.836 n=7+6) |
ParseFungibleToken/With_memory_metering-2 | 215µs ± 2% | 213µs ± 2% | ~ | (p=0.445 n=7+6) |
ParseFungibleToken/Without_memory_metering-2 | 166µs ± 2% | 166µs ± 2% | ~ | (p=0.805 n=7+7) |
ParseInfix-2 | 7.87µs ± 2% | 7.94µs ± 3% | ~ | (p=0.365 n=7+7) |
QualifiedIdentifierCreation/One_level-2 | 2.35ns ± 0% | 2.35ns ± 0% | ~ | (p=0.233 n=6+7) |
QualifiedIdentifierCreation/Three_levels-2 | 141ns ± 4% | 141ns ± 1% | ~ | (p=0.535 n=7+7) |
RuntimeFungibleTokenTransfer-2 | 755µs ± 6% | 549µs ± 4% | −27.23% | (p=0.001 n=6+7) |
RuntimeResourceDictionaryValues-2 | 5.35ms ± 6% | 5.35ms ± 5% | ~ | (p=0.620 n=7+7) |
RuntimeScriptNoop-2 | 19.6µs ±24% | 15.2µs ± 3% | ~ | (p=0.097 n=7+7) |
ValueIsSubtypeOfSemaType-2 | 89.9ns ± 5% | 88.6ns ± 1% | ~ | (p=0.295 n=7+6) |
alloc/op | delta | |||
CheckContractInterfaceFungibleTokenConformance-2 | 61.5kB ± 0% | 61.5kB ± 0% | ~ | (p=0.592 n=7+7) |
ContractInterfaceFungibleToken-2 | 23.9kB ± 0% | 23.9kB ± 0% | ~ | (p=1.000 n=7+7) |
InterpretRecursionFib-2 | 1.23MB ± 0% | 1.23MB ± 0% | ~ | (p=0.409 n=7+7) |
NewInterpreter/new_interpreter-2 | 848B ± 0% | 848B ± 0% | ~ | (all equal) |
NewInterpreter/new_sub-interpreter-2 | 264B ± 0% | 264B ± 0% | ~ | (all equal) |
ParseArray-2 | 2.79MB ± 2% | 2.77MB ± 0% | ~ | (p=0.867 n=7+6) |
ParseDeploy/byte_array-2 | 4.47MB ± 3% | 4.45MB ± 3% | ~ | (p=0.779 n=7+7) |
ParseDeploy/decode_hex-2 | 214kB ± 0% | 214kB ± 0% | ~ | (p=0.343 n=7+7) |
ParseFungibleToken/With_memory_metering-2 | 36.3kB ± 0% | 36.3kB ± 0% | ~ | (p=0.837 n=7+7) |
ParseFungibleToken/Without_memory_metering-2 | 36.3kB ± 0% | 36.3kB ± 0% | ~ | (p=0.152 n=7+7) |
ParseInfix-2 | 2.17kB ± 0% | 2.17kB ± 0% | ~ | (p=0.449 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 | 111kB ± 1% | 110kB ± 0% | −0.90% | (p=0.011 n=7+7) |
RuntimeResourceDictionaryValues-2 | 2.27MB ± 0% | 2.27MB ± 0% | ~ | (p=0.456 n=7+7) |
RuntimeScriptNoop-2 | 8.65kB ± 1% | 8.65kB ± 0% | ~ | (p=0.710 n=7+7) |
ValueIsSubtypeOfSemaType-2 | 48.0B ± 0% | 48.0B ± 0% | ~ | (all equal) |
allocs/op | delta | |||
CheckContractInterfaceFungibleTokenConformance-2 | 1.03k ± 0% | 1.03k ± 0% | ~ | (all equal) |
ContractInterfaceFungibleToken-2 | 426 ± 0% | 426 ± 0% | ~ | (all equal) |
InterpretRecursionFib-2 | 22.5k ± 0% | 22.5k ± 0% | ~ | (all equal) |
NewInterpreter/new_interpreter-2 | 14.0 ± 0% | 14.0 ± 0% | ~ | (all equal) |
NewInterpreter/new_sub-interpreter-2 | 5.00 ± 0% | 5.00 ± 0% | ~ | (all equal) |
ParseArray-2 | 70.0k ± 0% | 70.0k ± 0% | ~ | (p=1.000 n=7+7) |
ParseDeploy/byte_array-2 | 105k ± 0% | 105k ± 0% | ~ | (p=1.000 n=7+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 | 2.20k ± 0% | 2.20k ± 0% | ~ | (all equal) |
RuntimeResourceDictionaryValues-2 | 36.9k ± 0% | 36.9k ± 0% | ~ | (p=0.091 n=5+7) |
RuntimeScriptNoop-2 | 143 ± 0% | 143 ± 0% | ~ | (all equal) |
ValueIsSubtypeOfSemaType-2 | 1.00 ± 0% | 1.00 ± 0% | ~ | (all equal) |
Codecov Report
Merging #1905 (be13c44) into feature/external-cadence-encoding (377e36c) will increase coverage by
1.12%
. The diff coverage is79.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.
Closing in favor of redesigned solution captured in: https://github.com/onflow/cadence/issues/2157