Skip to content

perf: eliminate macOS discovery timeout tail (Fixes #504) - #506

Merged
Karthik Nadig (karthiknadig) merged 8 commits into
mainfrom
perf/issue-504
Aug 11, 2026
Merged

perf: eliminate macOS discovery timeout tail (Fixes #504)#506
Karthik Nadig (karthiknadig) merged 8 commits into
mainfrom
perf/issue-504

Conversation

@karthiknadig

@karthiknadig Karthik Nadig (karthiknadig) commented Aug 10, 2026

Copy link
Copy Markdown
Member

Summary

Eliminate the deterministic macOS cold-refresh tail caused by duplicate serialized probes of Apple's /usr/bin/python3 shim. Resolve active developer Python executables from filesystem state instead, while preserving legacy /usr/bin/python behavior.

Changes

  • resolve DEVELOPER_DIR, xcode_select_link, and standard developer-directory fallbacks without spawning Python
  • reuse file-based mapping in Xcode and Command Line Tools locators
  • skip unresolved Apple Python 3 shims before generic process probing
  • collect phase/locator diagnostics outside timed refreshes and retain privacy-safe timeout counts beyond the bounded stderr tail
  • require complete environment/manager inventory from iteration one
  • cover selected-Xcode, CommandLineTools, missing-target, versioned-shim, legacy-shim, timeout-eviction, and measurement-isolation behavior

Validation

  • full CI, lint, CodeQL, Linux/Windows coverage, and all enforced performance gates pass
  • repeat macOS run: P50 120ms vs 99ms baseline; P95 1,256ms vs 30,320ms; 0 probe timeouts; 10/10 environments from iteration one
  • repeat Windows/Linux P50: 138ms/53ms vs 124ms/55ms baselines; inventories unchanged
  • exact-head Copilot review: 7/7 files, 0 comments, 0 unresolved threads

Fixes #504

Pin comparisons to the exact PR base, fail invalid or regressed performance and coverage snapshots, and harden the E2E JSONRPC client against buffered-output loss and stderr backpressure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Capture existing RefreshProgress notifications in the E2E benchmark and emit deterministic phase and locator percentile distributions so cold-tail latency can be attributed before product changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Classify existing timeout warnings into privacy-safe categories in the E2E benchmark so the macOS cold tail can be tied to exact fallback probe counts without exposing paths.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Map Apple /usr/bin/python3 aliases through the active developer directory, remove duplicate Xcode and CommandLineTools probes, and skip unresolved shims before the spawn fallback.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 targets the macOS cold-refresh ~30s tail latency by avoiding duplicate serialized spawn-based resolution of Apple’s /usr/bin/python3 shim. It adds filesystem-based mapping from the shim to the active developer toolchain Python (Xcode / CommandLineTools) and extends the e2e performance harness to collect/aggregate RefreshProgress telemetry and privacy-safe interpreter timeout categories.

Changes:

  • Add macOS-specific utilities to detect and resolve /usr/bin/python3 (and python3.<minor>) shims to the active developer directory without spawning Python.
  • Update macOS Xcode and Command Line Tools locators to reuse the file-based mapping and add /usr/bin/python3 as an alias only when it truly matches the discovered interpreter.
  • Enhance the e2e performance test harness to collect RefreshProgress telemetry, assert phase coverage per iteration, and classify interpreter probe timeouts into privacy-safe buckets.
Show a summary per file
File Description
crates/pet/tests/e2e_performance.rs Collects RefreshProgress notifications, aggregates phase/locator timing stats, and classifies interpreter spawn timeouts into privacy-safe labels for CI metrics.
crates/pet/src/locators.rs Skips spawn-based resolution for unresolved macOS /usr/bin/python3* shims during fallback resolution to avoid deterministic timeout tails.
crates/pet-python-utils/src/macos.rs New filesystem-based resolver for macOS system Python shims (developer dir selection + alias handling) without spawning.
crates/pet-python-utils/src/lib.rs Exposes the new macos module.
crates/pet-mac-xcode/src/lib.rs Resolves /usr/bin/python3* inputs via file mapping and adds /usr/bin/python3 alias via the shared helper instead of spawning.
crates/pet-mac-commandlinetools/src/lib.rs Same as Xcode locator: file-based shim mapping + shared alias injection, removing spawn-based probing of /usr/bin/python3.

Review details

Tip

Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Lite

Base automatically changed from fix/issue-503 to main August 10, 2026 21:14
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

Performance Report (Linux)

Result: ✅ Within regression budgets

Metric PR Baseline Delta Change Blocking budget Status
Server startup P50 1ms 0ms +1ms +inf% >5ms and >100% 🔺
Server startup P95 1ms 1ms +0ms +0.0% >50ms and >200%
Full refresh P50 56ms 55ms +1ms +1.8% >25ms and >30% 🔺
Full refresh P95 352ms 299ms +53ms +17.7% >1000ms and >100% 🔺
Time to first environment P50 13ms 11ms +2ms +18.2% >20ms and >100% 🔺
Time to first environment P95 19ms 15ms +4ms +26.7% >250ms and >100% 🔺
Workload PR Baseline
Environments 5 5
Managers 1 1

A regression must exceed both the documented absolute and relative budget. Environment and manager inventories must match exactly.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

Performance Report (macOS)

Result: ✅ Within regression budgets

Metric PR Baseline Delta Change Blocking budget Status
Server startup P50 78ms 69ms +9ms +13.0% >100ms and >50% 🔺
Server startup P95 691ms 7356ms -6665ms -90.6% >10000ms and >100%
Full refresh P50 163ms 99ms +64ms +64.6% >100ms and >50% 🔺
Full refresh P95 1435ms 30320ms -28885ms -95.3% >5000ms and >25%
Time to first environment P50 102ms 99ms +3ms +3.0% >150ms and >50% 🔺
Time to first environment P95 745ms 7433ms -6688ms -90.0% >10000ms and >100%
Workload PR Baseline
Environments 10 10
Managers 1 1

A regression must exceed both the documented absolute and relative budget. Environment and manager inventories must match exactly.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

Performance Report (Windows)

Result: ✅ Within regression budgets

Metric PR Baseline Delta Change Blocking budget Status
Server startup P50 10ms 9ms +1ms +11.1% >10ms and >50% 🔺
Server startup P95 13ms 12ms +1ms +8.3% >50ms and >100% 🔺
Full refresh P50 163ms 124ms +39ms +31.5% >50ms and >30% 🔺
Full refresh P95 492ms 2533ms -2041ms -80.6% >5000ms and >100%
Time to first environment P50 38ms 21ms +17ms +81.0% >25ms and >50% 🔺
Time to first environment P95 71ms 80ms -9ms -11.2% >500ms and >100%
Workload PR Baseline
Environments 10 10
Managers 2 2

A regression must exceed both the documented absolute and relative budget. Environment and manager inventories must match exactly.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

Test Coverage Report (Linux)

Result: ✅ Within regression budget

Metric PR Baseline Delta
Lines 80.815% 80.693% +0.121pp
Functions 84.806% 84.791% +0.015pp

Allowed numerical tolerance: 0.01 percentage points.

@github-actions

github-actions Bot commented Aug 10, 2026

Copy link
Copy Markdown

Test Coverage Report (Windows)

Result: ✅ Within regression budget

Metric PR Baseline Delta
Lines 78.207% 78.065% +0.142pp
Functions 81.533% 81.467% +0.066pp

Allowed numerical tolerance: 0.01 percentage points.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 6/6 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (1)

crates/pet/tests/e2e_performance.rs:418

  • interpreter_probe_timeout_labels() derives timeout counts by scanning stderr_tail, but that tail is explicitly bounded (STDERR_TAIL_LINES = 100). If PET emits >100 stderr lines after a spawn timeout, the timeout warning can be evicted from the tail and the test will undercount (potentially masking a regression).

Consider tracking timeout labels/counts in spawn_stderr_reader as lines are read (store only matching labels/counters, which should stay small) instead of scanning the bounded tail for matches.

    fn interpreter_probe_timeout_labels(&self) -> Vec<&'static str> {
        self.stderr_tail
            .lock()
            .expect("PET stderr tail mutex poisoned")
            .iter()
  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 7/7 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@karthiknadig
Karthik Nadig (karthiknadig) merged commit f0c62d9 into main Aug 11, 2026
41 checks passed
@karthiknadig
Karthik Nadig (karthiknadig) deleted the perf/issue-504 branch August 11, 2026 14:41
Karthik Nadig (karthiknadig) added a commit that referenced this pull request Aug 11, 2026
## Summary

Recalibrate macOS P95 regression budgets now that #506 removed the
deterministic 30-second interpreter-probe tail. The new limits preserve
4-6x observed hosted-runner variance while blocking multi-second drift
that the old baseline-era limits allowed.

## Changes

- tighten startup P95 from 10,000ms to 750ms absolute headroom
- tighten full-refresh P95 from 5,000ms/25% to 1,000ms/50%
- tighten time-to-first P95 from 10,000ms to 750ms absolute headroom
- prove the worst observed post-fix run remains within budget
- prove 1.5s/2.5s/1.5s synthetic regressions now fail
- document calibration from three unchanged-content runs and the exact
merged baseline

## Validation

- `python -m unittest discover -s scripts/tests -p 'test_*.py' -v` (22
passed)
- worst observed macOS artifact passes against merged baseline `f0c62d9`

Fixes #507

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
pull Bot pushed a commit to tangzixuan/zed that referenced this pull request Aug 12, 2026
…#62534)

# Objective

Fixes zed-industries#62529.

Prevent Python toolchain discovery from executing Apple's
`/usr/bin/python3` Command Line Tools shim when no active developer
Python exists. Executing that unresolved shim causes macOS to repeatedly
prompt users to install the Command Line Tools, even when Python is
managed through Nix, uv, or pyenv.

## Solution

Update Python Environment Tools (PET) to `bb8e046`, which includes
microsoft/python-environment-tools#506. That upstream change resolves
active Xcode and Command Line Tools Python executables from filesystem
state and skips unresolved macOS system Python shims before generic
process probing.

Adapt Zed to the updated PET API by:

- displaying the newly supported Hatch environment kind
- passing no refresh identifier when running in-process environment
discovery

## Testing

- `cargo check -p languages --locked`
- PET unit tests covering unresolved macOS system Python shims
- The Zed compilation check was run on Linux; the original dialog
reproduction was not manually tested on macOS.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed Python toolchain discovery prompting installation of Apple
Command Line Tools when using a separately managed Python installation.
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.

Eliminate macOS cold-refresh 30-second tail latency

3 participants