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

Nil elements when reslicing #1547

Merged
merged 1 commit into from
Apr 1, 2022
Merged

Conversation

turbolent
Copy link
Member

Description

When reslicing to pop pointer-typed elements, ensure to nil the removed elements to not leak memory.
See https://github.com/golang/go/wiki/SliceTricks#delete-without-preserving-order


  • 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

@turbolent turbolent self-assigned this Mar 31, 2022
@github-actions
Copy link

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit c63336c
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-218.1ms ± 3%18.4ms ± 5%~(p=0.259 n=7+7)
RuntimeFungibleTokenTransfer-21.49ms ±31%1.54ms ±22%~(p=1.000 n=7+7)
ParseArray-216.2ms ± 5%16.2ms ± 4%~(p=0.628 n=7+6)
ParseDeploy/byte_array-224.8ms ± 3%24.7ms ± 6%~(p=0.628 n=7+6)
ParseDeploy/decode_hex-21.53ms ± 1%1.53ms ± 7%~(p=0.731 n=6+7)
ParseInfix-210.6µs ± 3%10.7µs ± 1%~(p=0.343 n=7+5)
ParseFungibleToken-2245µs ± 2%242µs ± 4%~(p=0.534 n=6+7)
QualifiedIdentifierCreation/One_level-23.48ns ± 2%3.56ns ± 4%~(p=0.234 n=6+7)
QualifiedIdentifierCreation/Three_levels-2184ns ± 4%186ns ± 3%~(p=0.251 n=6+7)
CheckContractInterfaceFungibleTokenConformance-2189µs ± 5%183µs ± 4%~(p=0.053 n=7+7)
InterpretRecursionFib-23.46ms ± 1%3.46ms ± 3%~(p=0.731 n=6+7)
NewInterpreter/new_interpreter-21.43µs ± 1%1.46µs ± 8%~(p=0.836 n=6+7)
NewInterpreter/new_sub-interpreter-22.77µs ± 2%2.82µs ± 9%~(p=0.945 n=6+7)
ContractInterfaceFungibleToken-252.8µs ± 2%51.3µs ± 3%−2.92%(p=0.014 n=6+7)
 
alloc/opdelta
RuntimeResourceDictionaryValues-24.05MB ± 0%4.05MB ± 0%+0.00%(p=0.003 n=7+5)
RuntimeFungibleTokenTransfer-2273kB ± 0%273kB ± 0%~(p=0.445 n=7+6)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
ContractInterfaceFungibleToken-226.6kB ± 0%26.6kB ± 0%~(p=0.462 n=7+7)
CheckContractInterfaceFungibleTokenConformance-266.2kB ± 0%66.2kB ± 0%~(p=1.000 n=7+7)
InterpretRecursionFib-21.26MB ± 0%1.26MB ± 0%~(p=1.000 n=7+7)
NewInterpreter/new_interpreter-2848B ± 0%848B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.34kB ± 0%1.34kB ± 0%~(all equal)
 
allocs/opdelta
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.147 n=7+6)
RuntimeFungibleTokenTransfer-24.54k ± 0%4.54k ± 0%~(p=0.755 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
ContractInterfaceFungibleToken-2458 ± 0%458 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
InterpretRecursionFib-226.2k ± 0%26.2k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-240.0 ± 0%40.0 ± 0%~(all equal)
 

@turbolent turbolent merged commit ba98f65 into master Apr 1, 2022
@turbolent turbolent deleted the bastian/improve-memory-usage branch April 1, 2022 16:34
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.

3 participants