Skip to content

Commit

Permalink
Speed up find_commands() on WSL (#13035)
Browse files Browse the repository at this point in the history
On WSL, the entire Windows PATH is inherited, and calling `isfile`
(specifically, `os.stat`) across the filesystem boundary is
extremely slow. Delaying the check until after pattern matching
speeds things up considerably.
  • Loading branch information
otaithleigh committed Aug 28, 2023
1 parent 0038a45 commit ae409f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 1 addition & 3 deletions conda/cli/find_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ def find_commands(include_others=True):
if not isdir(dir_path):
continue
for fn in os.listdir(dir_path):
if not isfile(join(dir_path, fn)):
continue
m = pat.match(fn)
if m:
if m and isfile(join(dir_path, fn)):
res.add(m.group(1))
return tuple(sorted(res))
19 changes: 19 additions & 0 deletions news/13035-faster-find-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
### Enhancements

* <news item>

### Bug fixes

* Fix performance regression of basic commands (e.g., `conda info`) on WSL. (#13035)

### Deprecations

* <news item>

### Docs

* <news item>

### Other

* <news item>

0 comments on commit ae409f8

Please sign in to comment.