Skip to content

Switch to local env var cache, remove broken (now unused) InMemoryInterpreterSpecificCache#15098

Merged
jakebailey merged 12 commits into
microsoft:mainfrom
jakebailey:fix-env-caching
Jan 7, 2021
Merged

Switch to local env var cache, remove broken (now unused) InMemoryInterpreterSpecificCache#15098
jakebailey merged 12 commits into
microsoft:mainfrom
jakebailey:fix-env-caching

Conversation

@jakebailey
Copy link
Copy Markdown
Member

@jakebailey jakebailey commented Jan 6, 2021

For #3805

The InMemoryInterpreterSpecificCache was unfortunately fatally flawed; its cache key calculation was done globally (behaved differently in tests which let the bug go unnoticed) and returned different results seemingly randomly based on which part of the workspace you queried (undefined resource versus folder versus file).

The environment provider is the only user of this cache class, and to clear the caches it used a clear function that operated on the global cache; however, the previously mentioned inconsistency meant that it wouldn't actually clear everything out of the cache, as a single environment file could affect multiple cache entries.

We still want to be able to cache things, so instead use the (actually functional) InMemoryCache within the environment variable provider, and clear the caches when an environment file changes.

I've added a test for modifying the environment file, and also realized that the tests always returned a shared envfile object, meaning changing the faked file would always appear to have worked; explicit copies are added to work around this.

The new test would still pass on the old code, however, as there was no good way to actually force the cache to behave as it does at runtime; the old cache code bypassed any interfaces to go to the vscode API directly.

The now-unused InMemoryInterpreterSpecificCache and its tests have been removed (and a little cruft from it cleaned up).

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

Copy link
Copy Markdown

@karrtikr karrtikr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests seem to be failing.

@karrtikr karrtikr self-requested a review January 6, 2021 21:36
@jakebailey
Copy link
Copy Markdown
Member Author

Odd. Will look; seems to be the with-VSC tests.

@jakebailey
Copy link
Copy Markdown
Member Author

Not sure why those broke, but the tests didn't seem to be adding all of the services they need. Gross tests that don't explicitly create things...

@codecov-io
Copy link
Copy Markdown

codecov-io commented Jan 7, 2021

Codecov Report

Merging #15098 (0bf919f) into main (4284057) will decrease coverage by 0%.
The diff coverage is 92%.

@@          Coverage Diff           @@
##            main   #15098   +/-   ##
======================================
- Coverage     65%      65%   -1%     
======================================
  Files        557      557           
  Lines      26220    26182   -38     
  Branches    3729     3721    -8     
======================================
- Hits       17061    17032   -29     
+ Misses      8463     8460    -3     
+ Partials     696      690    -6     
Impacted Files Coverage Δ
src/client/common/utils/cacheUtils.ts 89% <77%> (+6%) ⬆️
src/client/common/utils/decorators.ts 78% <100%> (-1%) ⬇️
...t/common/variables/environmentVariablesProvider.ts 93% <100%> (+1%) ⬆️
src/client/interpreter/activation/service.ts 76% <100%> (ø)

@jakebailey
Copy link
Copy Markdown
Member Author

@karrtikr The PR's been updated, if you wanted to take a look again.

@jakebailey jakebailey merged commit 48abee1 into microsoft:main Jan 7, 2021
@jakebailey jakebailey deleted the fix-env-caching branch January 7, 2021 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants