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

[LS] Remove caching of checkers for imported programs #1572

Merged
merged 16 commits into from
Apr 13, 2022

Conversation

devbugging
Copy link
Contributor

@devbugging devbugging commented Apr 12, 2022

Closes #1571

Description

When LS is resolving the imports it uses a cached checker which doesn't include any changes to the imported program resulting in the current program not seeing those changes in diagnostics / code completions. This PR makes sure the checker is initialized every time, which arguably can be expensive but it's meant to be a quick patch on the blocking problem in production, a better way would be to have a "reversed" dependency tree and figure out which dependencies actually change and not just do a new re-init every time, this is been documented in an issue for future #1570.


  • 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

@devbugging devbugging self-assigned this Apr 12, 2022
@devbugging devbugging changed the title Resolving Imports Not Using Cached Checker Remove caching of checkers for imported programs Apr 12, 2022
@devbugging devbugging changed the title Remove caching of checkers for imported programs [LS] Remove caching of checkers for imported programs Apr 12, 2022
@github-actions
Copy link

github-actions bot commented Apr 12, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 07c27c2
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
ParseInfix-28.28µs ± 1%8.37µs ± 1%+1.11%(p=0.004 n=7+7)
ParseFungibleToken-2180µs ± 1%182µs ± 0%+0.74%(p=0.005 n=7+6)
RuntimeFungibleTokenTransfer-21.13ms ±29%1.19ms ±24%~(p=0.902 n=7+7)
ParseDeploy/byte_array-219.5ms ± 2%19.6ms ± 3%~(p=0.318 n=7+7)
ParseDeploy/decode_hex-21.15ms ± 1%1.16ms ± 2%~(p=0.181 n=6+7)
ParseArray-212.2ms ± 3%12.4ms ± 3%~(p=0.456 n=7+7)
QualifiedIdentifierCreation/One_level-22.34ns ± 0%2.34ns ± 0%~(p=0.219 n=6+7)
QualifiedIdentifierCreation/Three_levels-2138ns ± 1%139ns ± 1%~(p=0.273 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2131µs ± 1%131µs ± 1%~(p=0.710 n=7+7)
ContractInterfaceFungibleToken-239.0µs ± 1%39.1µs ± 1%~(p=0.295 n=7+6)
NewInterpreter/new_interpreter-21.12µs ± 1%1.13µs ± 1%~(p=0.134 n=7+7)
NewInterpreter/new_sub-interpreter-22.20µs ± 0%2.20µs ± 1%~(p=0.646 n=6+7)
InterpretRecursionFib-22.79ms ± 1%2.69ms ± 0%−3.60%(p=0.001 n=7+6)
RuntimeResourceDictionaryValues-213.4ms ± 2%6.3ms ± 4%−52.98%(p=0.001 n=7+7)
 
alloc/opdelta
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.2kB ± 0%66.2kB ± 0%~(all equal)
ContractInterfaceFungibleToken-226.6kB ± 0%26.6kB ± 0%~(p=0.462 n=7+7)
NewInterpreter/new_interpreter-2848B ± 0%848B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.34kB ± 0%1.34kB ± 0%~(all equal)
RuntimeFungibleTokenTransfer-2273kB ± 0%273kB ± 0%−0.10%(p=0.001 n=7+7)
InterpretRecursionFib-21.26MB ± 0%1.14MB ± 0%−9.30%(p=0.000 n=6+7)
RuntimeResourceDictionaryValues-24.05MB ± 0%2.25MB ± 0%−44.36%(p=0.001 n=7+7)
 
allocs/opdelta
RuntimeFungibleTokenTransfer-24.54k ± 0%4.58k ± 0%+1.00%(p=0.001 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
ContractInterfaceFungibleToken-2458 ± 0%458 ± 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)
InterpretRecursionFib-226.2k ± 0%23.8k ± 0%−9.30%(p=0.001 n=7+7)
RuntimeResourceDictionaryValues-2102k ± 0%38k ± 0%−63.03%(p=0.001 n=7+7)
 

@codecov
Copy link

codecov bot commented Apr 13, 2022

Codecov Report

Merging #1572 (c96eeb5) into master (c63336c) will decrease coverage by 0.03%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #1572      +/-   ##
==========================================
- Coverage   74.69%   74.65%   -0.04%     
==========================================
  Files         289      288       -1     
  Lines       55625    55364     -261     
==========================================
- Hits        41549    41332     -217     
+ Misses      12581    12535      -46     
- Partials     1495     1497       +2     
Flag Coverage Δ
unittests 74.65% <ø> (-0.04%) ⬇️

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

Impacted Files Coverage Δ
runtime/interpreter/function.go 52.71% <0.00%> (-4.54%) ⬇️
runtime/interpreter/simplecompositevalue.go 59.63% <0.00%> (-3.92%) ⬇️
runtime/sema/simple_type.go 92.30% <0.00%> (-3.85%) ⬇️
runtime/interpreter/accountkeys.go 77.27% <0.00%> (-0.99%) ⬇️
runtime/convertValues.go 77.95% <0.00%> (-0.88%) ⬇️
runtime/interpreter/accountcontracts.go 81.13% <0.00%> (-0.69%) ⬇️
runtime/interpreter/block.go 90.00% <0.00%> (-0.48%) ⬇️
runtime/interpreter/value.go 63.63% <0.00%> (-0.37%) ⬇️
runtime/stdlib/rlp.go 86.00% <0.00%> (-0.14%) ⬇️
runtime/interpreter/account.go 92.48% <0.00%> (-0.12%) ⬇️
... and 20 more

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 c63336c...c96eeb5. Read the comment docs.

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.

[LS] New members not visible from imported contracts
2 participants