Skip to content

Fix windows path locator performance.#15177

Merged
ericsnowcurrently merged 34 commits intomicrosoft:mainfrom
ericsnowcurrently:fix-windows-path-locator-performance
Feb 1, 2021
Merged

Fix windows path locator performance.#15177
ericsnowcurrently merged 34 commits intomicrosoft:mainfrom
ericsnowcurrently:fix-windows-path-locator-performance

Conversation

@ericsnowcurrently
Copy link
Copy Markdown

The fix here is to use a timeout. When we hit it (with large directories like \windows\system32), we fall back to trying some known Python executables.

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • [ ] Has telemetry for enhancements.
  • [ ] The wiki is updated with any design decisions/details.

@ericsnowcurrently ericsnowcurrently added the no-changelog No news entry required label Jan 19, 2021
@ericsnowcurrently ericsnowcurrently added the skip tests Updates to tests unnecessary label Jan 19, 2021
@ericsnowcurrently ericsnowcurrently force-pushed the fix-windows-path-locator-performance branch from c46b693 to 1ecc352 Compare January 20, 2021 00:03
@karthiknadig
Copy link
Copy Markdown
Member

I think we can simplify this, when we are looking for things in PATH we are anyway going to look for python.exe or python binary (and a few combinations of those. Why do we even have to get the full list of files on path at all? I don't see a need for fallback. I think what we do in the fallback should be the main thing. We can have a separate thing in the background that looks at path in lot more detail by examining each file in the directory.

This way we will have the fast detection of anything that is common, and eventual detection of anything that is uncommon python executable pattern.

@karrtikr
Copy link
Copy Markdown

I agree with @karthiknadig, if we're just looking for python.exe and python, using the fallback directly should be the simplest soln for now.
FWIW I think we should look into the old locators, and how they are working just fine when they do the same thing. Something is going wrong with the new setup somewhere.

We can have a separate thing in the background that looks at path in lot more detail by examining each file in the directory.

This practically never finishes, it'll eventually hang the extension. So we cannot have this running even in background until we find the fix.

@karrtikr karrtikr removed their request for review January 20, 2021 23:14
@karrtikr
Copy link
Copy Markdown

Removing my review until this is ready to be reviewed again.

@karrtikr karrtikr closed this Jan 20, 2021
@karrtikr karrtikr reopened this Jan 20, 2021
@github-actions github-actions bot requested a review from kimadeline January 20, 2021 23:14
@ericsnowcurrently ericsnowcurrently requested review from karrtikr and removed request for kimadeline January 20, 2021 23:15
@karrtikr
Copy link
Copy Markdown

Accidently closed it, sorry.

@ericsnowcurrently
Copy link
Copy Markdown
Author

@karthiknadig, @karrtikr, I've updated the PR to deal with the quirks on Windows. Now we do not watch Windows\system32 and we avoid unnecessary lstat() calls. It should be similar in performance to the old code now.

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.

My stance is we should remove all watchers for windows path locator for now. We can add this as an enhancement later if necessary.

@karthiknadig
Copy link
Copy Markdown
Member

There is no need to watch for files on PATH. We don't do that now, This can be expensive on slower machines. We also don't for other platforms.

@ericsnowcurrently
Copy link
Copy Markdown
Author

If we are just copying over the old behavior then I'm fine with dropping the watcher stuff. However, my understanding was that we were implementing the new discovery code in the proper way, regardless of how we were doing it before.

@ericsnowcurrently ericsnowcurrently force-pushed the fix-windows-path-locator-performance branch from 51e095d to caa4c05 Compare January 26, 2021 19:08
@ericsnowcurrently
Copy link
Copy Markdown
Author

In the interest of getting this wrapped up sooner rather than later, I'll drop the watcher stuff for now.

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.

I understand significant work has been done but we should remove the code introduced with this PR which is no longer used in fixing windows path locator performance. We can add that code back later if and when we need to use it. Other than that, LGTM.

@ericsnowcurrently ericsnowcurrently force-pushed the fix-windows-path-locator-performance branch from 35c0c3d to 1040ca2 Compare January 28, 2021 18:34
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #15177 (1040ca2) into main (95c5f28) will decrease coverage by 0%.
The diff coverage is 56%.

@@          Coverage Diff           @@
##            main   #15177   +/-   ##
======================================
- Coverage     64%      64%   -1%     
======================================
  Files        558      558           
  Lines      26656    26716   +60     
  Branches    3851     3854    +3     
======================================
+ Hits       17315    17353   +38     
- Misses      8634     8649   +15     
- Partials     707      714    +7     
Impacted Files Coverage Δ
src/client/common/platform/types.ts 100% <ø> (ø)
src/client/interpreter/contracts.ts 100% <ø> (ø)
src/client/pythonEnvironments/base/info/index.ts 100% <ø> (ø)
.../pythonEnvironments/common/externalDependencies.ts 62% <ø> (-2%) ⬇️
...nments/discovery/locators/services/pyenvLocator.ts 68% <0%> (ø)
...rc/client/pythonEnvironments/common/commonUtils.ts 59% <40%> (-16%) ⬇️
src/client/pythonEnvironments/base/info/env.ts 72% <50%> (-1%) ⬇️
...pythonEnvironments/common/pythonBinariesWatcher.ts 53% <56%> (+18%) ⬆️
...nments/base/locators/lowLevel/fsWatchingLocator.ts 77% <75%> (-8%) ⬇️
src/client/common/platform/fileSystem.ts 81% <100%> (ø)
... and 13 more

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.

Please verify that the extension loads on Windows when in experiment. Overall LGTM otherwise.

@ericsnowcurrently
Copy link
Copy Markdown
Author

@karthiknadig ETA on a review?

@ericsnowcurrently
Copy link
Copy Markdown
Author

@karrtikr, FYI, I tried my branch on my Windows laptop and it worked fine. However, I recall that this impacted other people more than it did me. Would you mind trying it out, just to double-check?

@karrtikr
Copy link
Copy Markdown

karrtikr commented Feb 1, 2021

@ericsnowcurrently Yeah okay I'll try it out.

@karrtikr
Copy link
Copy Markdown

karrtikr commented Feb 1, 2021

@ericsnowcurrently Works for me 👍 Although I see that the paths discovered by this locator are lowercased so they appear to be different than the others. ~ is not used to simplify those paths.

image

@ericsnowcurrently
Copy link
Copy Markdown
Author

@ericsnowcurrently Works for me 👍

Great! Thanks!

Although I see that the paths discovered by this locator are lowercased so they appear to be different than the others. ~ is not used to simplify those paths.

Hmm, I don't see anything in the PR that might have caused either behavior directly (other than maybe the glob code). I'll open an issue to investigate.

@ericsnowcurrently ericsnowcurrently merged commit 4fc88d0 into microsoft:main Feb 1, 2021
@ericsnowcurrently ericsnowcurrently deleted the fix-windows-path-locator-performance branch February 1, 2021 22:11
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.91304% with 53 lines in your changes missing coverage. Please review.
✅ Project coverage is 64%. Comparing base (95c5f28) to head (1040ca2).
⚠️ Report is 2569 commits behind head on main.

Files with missing lines Patch % Lines
...rc/client/pythonEnvironments/common/commonUtils.ts 40% 35 Missing and 4 partials ⚠️
...nments/base/locators/lowLevel/fsWatchingLocator.ts 75% 4 Missing and 3 partials ⚠️
...pythonEnvironments/common/pythonBinariesWatcher.ts 56% 5 Missing and 2 partials ⚠️
Additional details and impacted files
@@          Coverage Diff           @@
##            main   #15177   +/-   ##
======================================
- Coverage     64%      64%   -1%     
======================================
  Files        558      558           
  Lines      26656    26716   +60     
  Branches    3851     3854    +3     
======================================
+ Hits       17315    17353   +38     
- Misses      8634     8649   +15     
- Partials     707      714    +7     
Files with missing lines Coverage Δ
src/client/common/platform/fileSystem.ts 81% <100%> (ø)
src/client/common/platform/types.ts 100% <ø> (ø)
.../pythonEnvironments/common/externalDependencies.ts 62% <ø> (-2%) ⬇️
...discovery/locators/services/windowsStoreLocator.ts 100% <100%> (ø)
...nments/base/locators/lowLevel/fsWatchingLocator.ts 77% <75%> (-8%) ⬇️
...pythonEnvironments/common/pythonBinariesWatcher.ts 53% <56%> (+18%) ⬆️
...rc/client/pythonEnvironments/common/commonUtils.ts 59% <40%> (-16%) ⬇️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required skip tests Updates to tests unnecessary

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants