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

Improve allocations in checker #2127

Merged
merged 5 commits into from
Nov 18, 2022
Merged

Improve allocations in checker #2127

merged 5 commits into from
Nov 18, 2022

Conversation

turbolent
Copy link
Member

@turbolent turbolent commented Nov 8, 2022

Description

Improve function activations (55acc03), parameters (5ccf8c5), and type annotations (24a45bd): Pre-allocate and allocate activation structs inline, instead of unnecessarily as pointers. Also, avoid unnecessary allocations


  • 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 Nov 8, 2022
@turbolent turbolent changed the title improve function activations Improve allocations in checker Nov 8, 2022
@github-actions
Copy link

github-actions bot commented Nov 8, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit a7c776c
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-2126µs ± 3%118µs ± 1%−6.49%(p=0.001 n=7+6)
ContractInterfaceFungibleToken-242.9µs ± 3%40.0µs ± 0%−6.71%(p=0.003 n=7+5)
InterpretRecursionFib-22.47ms ± 2%2.41ms ± 1%−2.13%(p=0.002 n=6+6)
NewInterpreter/new_interpreter-21.19µs ± 2%1.22µs ± 1%+2.19%(p=0.003 n=7+6)
NewInterpreter/new_sub-interpreter-2650ns ± 1%652ns ± 1%~(p=0.180 n=6+6)
ParseArray-28.15ms ± 3%8.18ms ± 2%~(p=0.589 n=6+6)
ParseDeploy/byte_array-212.4ms ± 2%12.3ms ± 2%~(p=0.456 n=7+7)
ParseDeploy/decode_hex-21.23ms ± 1%1.24ms ± 2%~(p=0.805 n=7+7)
ParseFungibleToken/With_memory_metering-2187µs ± 1%191µs ± 3%~(p=0.073 n=6+7)
ParseFungibleToken/Without_memory_metering-2149µs ± 2%151µs ± 2%~(p=0.128 n=7+7)
ParseInfix-26.98µs ± 1%7.02µs ± 2%~(p=0.596 n=7+7)
QualifiedIdentifierCreation/One_level-22.35ns ± 0%2.35ns ± 0%~(p=1.000 n=6+6)
QualifiedIdentifierCreation/Three_levels-2140ns ± 4%137ns ± 1%−2.35%(p=0.010 n=7+7)
RuntimeFungibleTokenTransfer-2604µs ±24%701µs ±24%~(p=0.383 n=7+7)
RuntimeResourceDictionaryValues-25.40ms ± 5%5.47ms ± 2%~(p=0.456 n=7+7)
RuntimeScriptNoop-218.9µs ±50%23.0µs ±34%~(p=0.620 n=7+7)
SuperTypeInference/arrays-2315ns ± 1%309ns ± 1%−1.75%(p=0.001 n=6+7)
SuperTypeInference/composites-2132ns ± 0%130ns ± 0%−1.42%(p=0.001 n=7+6)
SuperTypeInference/integers-290.1ns ± 0%88.7ns ± 0%−1.58%(p=0.001 n=7+7)
ValueIsSubtypeOfSemaType-294.1ns ± 1%92.5ns ± 1%−1.71%(p=0.002 n=7+6)
 
alloc/opdelta
CheckContractInterfaceFungibleTokenConformance-251.0kB ± 0%49.7kB ± 0%−2.66%(p=0.001 n=7+7)
ContractInterfaceFungibleToken-224.7kB ± 0%24.0kB ± 0%−2.79%(p=0.001 n=7+7)
InterpretRecursionFib-21.00MB ± 0%1.00MB ± 0%~(all equal)
NewInterpreter/new_interpreter-2752B ± 0%752B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-2200B ± 0%200B ± 0%~(all equal)
ParseArray-22.74MB ± 3%2.75MB ± 5%~(p=0.628 n=6+7)
ParseDeploy/byte_array-24.19MB ± 3%4.19MB ± 3%~(p=0.805 n=7+7)
ParseDeploy/decode_hex-2214kB ± 0%214kB ± 0%~(p=0.645 n=7+7)
ParseFungibleToken/With_memory_metering-229.2kB ± 0%29.2kB ± 0%~(p=0.822 n=7+7)
ParseFungibleToken/Without_memory_metering-229.2kB ± 0%29.2kB ± 0%~(p=0.350 n=7+7)
ParseInfix-21.92kB ± 0%1.92kB ± 0%~(p=0.364 n=6+6)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
RuntimeFungibleTokenTransfer-2102kB ± 1%102kB ± 1%~(p=1.000 n=7+7)
RuntimeResourceDictionaryValues-22.28MB ± 0%2.28MB ± 0%~(p=0.097 n=7+7)
RuntimeScriptNoop-28.51kB ± 0%8.45kB ± 0%−0.72%(p=0.001 n=7+7)
SuperTypeInference/arrays-296.0B ± 0%96.0B ± 0%~(all equal)
SuperTypeInference/composites-20.00B 0.00B ~(all equal)
SuperTypeInference/integers-20.00B 0.00B ~(all equal)
ValueIsSubtypeOfSemaType-248.0B ± 0%48.0B ± 0%~(all equal)
 
allocs/opdelta
CheckContractInterfaceFungibleTokenConformance-2920 ± 0%815 ± 0%−11.41%(p=0.001 n=7+7)
ContractInterfaceFungibleToken-2444 ± 0%388 ± 0%−12.61%(p=0.001 n=7+7)
InterpretRecursionFib-218.9k ± 0%18.9k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-24.00 ± 0%4.00 ± 0%~(all equal)
ParseArray-259.6k ± 0%59.6k ± 0%~(p=0.286 n=7+7)
ParseDeploy/byte_array-289.4k ± 0%89.4k ± 0%~(p=0.286 n=7+7)
ParseDeploy/decode_hex-264.0 ± 0%64.0 ± 0%~(all equal)
ParseFungibleToken/With_memory_metering-2779 ± 0%779 ± 0%~(all equal)
ParseFungibleToken/Without_memory_metering-2779 ± 0%779 ± 0%~(all equal)
ParseInfix-248.0 ± 0%48.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-22.01k ± 0%1.98k ± 0%−1.54%(p=0.001 n=7+7)
RuntimeResourceDictionaryValues-237.0k ± 0%36.9k ± 0%−0.06%(p=0.001 n=7+7)
RuntimeScriptNoop-2137 ± 0%132 ± 0%−3.65%(p=0.001 n=7+7)
SuperTypeInference/arrays-23.00 ± 0%3.00 ± 0%~(all equal)
SuperTypeInference/composites-20.00 0.00 ~(all equal)
SuperTypeInference/integers-20.00 0.00 ~(all equal)
ValueIsSubtypeOfSemaType-21.00 ± 0%1.00 ± 0%~(all equal)
 

@turbolent turbolent requested a review from a team November 17, 2022 23:14
@codecov
Copy link

codecov bot commented Nov 17, 2022

Codecov Report

Merging #2127 (13b8c57) into master (a7c776c) will increase coverage by 0.00%.
The diff coverage is 96.15%.

@@           Coverage Diff           @@
##           master    #2127   +/-   ##
=======================================
  Coverage   77.97%   77.97%           
=======================================
  Files         308      308           
  Lines       64163    64180   +17     
=======================================
+ Hits        50029    50046   +17     
  Misses      12336    12336           
  Partials     1798     1798           
Flag Coverage Δ
unittests 77.97% <96.15%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
runtime/interpreter/statictype.go 83.11% <0.00%> (ø)
runtime/runtime.go 87.46% <ø> (ø)
runtime/sema/authaccount_contracts.go 100.00% <ø> (ø)
runtime/sema/check_event_declaration.go 94.23% <ø> (ø)
runtime/sema/crypto_algorithm_types.go 87.05% <ø> (ø)
runtime/sema/errors.go 91.88% <ø> (ø)
runtime/sema/meta_type.go 100.00% <ø> (ø)
runtime/sema/positioninfo.go 97.94% <ø> (ø)
runtime/sema/string_type.go 96.52% <ø> (ø)
runtime/stdlib/account.go 86.44% <ø> (ø)
... and 22 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@turbolent
Copy link
Member Author

@dsainati1 Could you please have a look?

@turbolent turbolent merged commit 7969b6b into master Nov 18, 2022
@turbolent turbolent deleted the bastian/optimize-checker branch November 18, 2022 18:11
@turbolent turbolent mentioned this pull request Jan 4, 2023
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants