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

Fix IsContainerType for CompositeType and InterfaceType #1335

Merged
merged 2 commits into from
Jan 5, 2022

Conversation

SupunS
Copy link
Member

@SupunS SupunS commented Jan 5, 2022

Port of https://github.com/dapperlabs/cadence-internal/pull/43 originally authored by Bastian.

Description

Description from original PR:

Some internal types, like HashAlgorithm, do not have any nested types.
Fix a crasher when a nested type of such types is accessed.

This is also an opportunity for a future optimization: user-defined composite types are always instantiated with an empty nested type map. We could lazily create it if needed and save an allocation in the common case where a type has no nested types.


  • 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

@github-actions
Copy link

github-actions bot commented Jan 5, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 2eb9cf7
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
RuntimeResourceDictionaryValues-219.2ms ± 4%19.3ms ± 5%~(p=0.902 n=7+7)
RuntimeFungibleTokenTransfer-21.72ms ±40%1.71ms ±20%~(p=1.000 n=7+7)
ParseArray-226.7ms ± 2%26.7ms ± 4%~(p=0.710 n=7+7)
ParseFungibleToken-2545µs ± 3%543µs ± 4%~(p=0.366 n=6+7)
ParseDeploy/byte_array-241.0ms ± 4%40.8ms ± 5%~(p=0.535 n=7+7)
ParseDeploy/decode_hex-21.66ms ± 2%1.69ms ± 4%~(p=0.295 n=6+7)
ParseInfix-229.1µs ± 3%28.7µs ± 5%~(p=0.318 n=7+7)
QualifiedIdentifierCreation/One_level-23.72ns ± 3%3.70ns ± 2%~(p=1.000 n=7+7)
QualifiedIdentifierCreation/Three_levels-2189ns ± 6%190ns ± 4%~(p=0.401 n=7+7)
ContractInterfaceFungibleToken-256.1µs ± 3%56.4µs ± 5%~(p=0.710 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2202µs ± 6%195µs ± 3%~(p=0.101 n=7+6)
InterpretRecursionFib-23.22ms ± 5%3.18ms ± 1%~(p=0.268 n=7+5)
NewInterpreter/new_interpreter-21.39µs ± 4%1.40µs ± 4%~(p=0.710 n=7+7)
NewInterpreter/new_sub-interpreter-22.74µs ± 3%2.72µs ± 3%~(p=0.913 n=7+6)
 
alloc/opdelta
RuntimeResourceDictionaryValues-24.04MB ± 0%4.04MB ± 0%~(p=0.902 n=7+7)
RuntimeFungibleTokenTransfer-2238kB ± 0%238kB ± 0%~(p=0.456 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
ContractInterfaceFungibleToken-226.5kB ± 0%26.5kB ± 0%~(p=1.000 n=7+7)
CheckContractInterfaceFungibleTokenConformance-265.7kB ± 0%65.7kB ± 0%~(p=0.385 n=7+6)
InterpretRecursionFib-21.24MB ± 0%1.24MB ± 0%~(p=0.192 n=7+7)
NewInterpreter/new_interpreter-2720B ± 0%720B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.18kB ± 0%1.18kB ± 0%~(all equal)
 
allocs/opdelta
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.883 n=6+7)
RuntimeFungibleTokenTransfer-24.54k ± 0%4.54k ± 0%~(p=1.000 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
ContractInterfaceFungibleToken-2457 ± 0%457 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
InterpretRecursionFib-225.0k ± 0%25.0k ± 0%~(all equal)
NewInterpreter/new_interpreter-211.0 ± 0%11.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-236.0 ± 0%36.0 ± 0%~(all equal)
 

@SupunS SupunS marked this pull request as ready for review January 5, 2022 22:06
@SupunS SupunS requested a review from turbolent as a code owner January 5, 2022 22:06
@SupunS SupunS merged commit c54ddd2 into master Jan 5, 2022
@SupunS SupunS deleted the supun/port-internal-43 branch January 5, 2022 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants