Skip to content

fix(winpython): narrow search paths and add discovery cache#456

Merged
karthiknadig merged 8 commits intomainfrom
feature/issue-453
May 7, 2026
Merged

fix(winpython): narrow search paths and add discovery cache#456
karthiknadig merged 8 commits intomainfrom
feature/issue-453

Conversation

@karthiknadig
Copy link
Copy Markdown
Member

Fixes #453.

The WinPython locator was scanning C:\, D:\, E:\, Program Files, ~/Downloads, ~/Desktop, and ~/Documents on every refresh — all Windows Defender hot-spots — to find a niche portable distribution. That inflated p90 refresh latency for every Windows user, regardless of whether WinPython was installed.

Changes

  • Restrict default search to %USERPROFILE%\WinPython.
  • Add opt-in WINPYTHON_HOME env var (single path or ;-separated list; each entry can be or contain a WinPython install).
  • Add a per-process discovery cache (Arc<Mutex<Option<Arc<Vec<...>>>>>), mirroring WindowsStore and WindowsRegistry, with SyncedDiscoveryState refresh persistence.
  • Extract build_search_paths(userprofile, winpython_home) as a pure helper so tests don't have to mutate process env.
  • New regression tests pinning the search-path policy and WINPYTHON_HOME parsing on both Windows and Unix.
  • README: document WINPYTHON_HOME and the new search-path policy.

try_from() behavior on a real WinPython executable is unchanged — it still walks parent directories looking for marker files / WPy* directory names.

@karthiknadig karthiknadig requested a review from Copilot May 7, 2026 20:50
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Performance Report (Linux) ✅

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 1ms 1ms 1ms 0ms 0%
Full Refresh 55ms 436ms 64ms -9ms -10.0%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Test Coverage Report (Linux)

Metric Value
Current Coverage 76.5%
Base Branch Coverage 76.6%
Delta -.1% ❌

Coverage decreased. Please add tests for new code.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Performance Report (macOS)

Metric PR (P50) PR (P95) Baseline (P50) Delta
Server Startup 93ms 648ms 103ms -10ms
Full Refresh 174ms 40351ms 175ms -1ms

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Performance Report (Windows) ✅

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 9ms 11ms 11ms -2ms -18.2%
Full Refresh 131ms 552ms 175ms -44ms -25.1%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

Test Coverage Report (Windows)

Metric Value
Current Coverage 74.19%
Base Branch Coverage 73.55%
Delta 0.64% ✅

Coverage increased! Great work!

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses Windows refresh performance regressions by narrowing the WinPython locator’s default discovery scope and adding an opt-in override for custom install locations, reducing expensive filesystem scans in Windows Defender hot paths.

Changes:

  • Restricts default WinPython discovery to %USERPROFILE%\WinPython, removing drive-root / common-user-folder scanning.
  • Adds WINPYTHON_HOME (supports multiple paths) and factors path policy into a pure build_search_paths(...) helper for testability.
  • Introduces a WinPython discovery cache and refresh-state syncing, and adds regression tests + README documentation.
Show a summary per file
File Description
crates/pet-winpython/src/lib.rs Implements narrowed search-path policy, adds WINPYTHON_HOME, introduces discovery caching + refresh-state syncing, and adds tests for the new behavior.
crates/pet-winpython/README.md Documents the new default search path behavior and how to opt in via WINPYTHON_HOME.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 4

Comment thread crates/pet-winpython/src/lib.rs
Comment thread crates/pet-winpython/src/lib.rs
Comment thread crates/pet-winpython/src/lib.rs
Comment thread crates/pet-winpython/src/lib.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 2

Comment thread crates/pet-winpython/src/lib.rs Outdated
Comment thread crates/pet-winpython/src/lib.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread crates/pet-winpython/src/lib.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment thread crates/pet-winpython/src/lib.rs
Comment thread crates/pet-winpython/src/lib.rs
Comment thread crates/pet-winpython/src/lib.rs
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new

@karthiknadig karthiknadig marked this pull request as ready for review May 7, 2026 21:43
…456)

Refactor discover_environments to delegate to discover_environments_in(locator, paths) so tests can inject paths instead of mutating env vars. Add tests for parent-dir and direct-install discovery, dedup contract, missing paths, find report loop, and all sync_refresh_state_from scope variants. Skip the redundant read_dir scan when search path is itself a WinPython install.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread crates/pet-winpython/src/lib.rs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 3/4 changed files
  • Comments generated: 0 new

@karthiknadig karthiknadig enabled auto-merge (squash) May 7, 2026 22:07
@karthiknadig karthiknadig merged commit 34b2d47 into main May 7, 2026
34 checks passed
@karthiknadig karthiknadig deleted the feature/issue-453 branch May 7, 2026 22:36
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.

Windows perf: WinPython locator scans C:\, D:\, E:\ drive roots on every refresh

3 participants