Skip to content

Avoid a second WSL launch for common path output#158

Open
camjac251 wants to merge 3 commits into
andy-5:developfrom
camjac251:perf/output-path-translation
Open

Avoid a second WSL launch for common path output#158
camjac251 wants to merge 3 commits into
andy-5:developfrom
camjac251:perf/output-path-translation

Conversation

@camjac251

Copy link
Copy Markdown

Summary

  • translate common WSL output paths without launching a second WSL process
  • preserve the selected-distribution fallback for ambiguous mappings
  • preserve unsupported non-UTF-8 output unchanged
  • replace the nightly-only benchmark with a stable, self-checking harness
  • remove checkout-name and login-shell assumptions from tests

Problem

Commands whose output contains absolute paths currently launch WSL again to run
wslpath. That second process is a large part of the wrapper's latency. A direct
conversion is only safe when the current Windows working directory proves the
distribution or drive mapping.

Implementation

The wrapper now derives either the active WSL UNC prefix or the Windows drive
from the working directory. It uses that evidence to translate matching output
in process. Unknown mount drives and other ambiguous paths retain the existing
wslpath fallback, including the selected distribution.

The benchmark now runs on stable Rust, resolves the exact Cargo-built binary,
warms up each case, rejects failed or empty runs, and supports
--iterations <N>.

Benchmark

In a representative 10-iteration run of the same output-translation case, the
mean fell from 428.02 ms to 333.66 ms: 94.36 ms, or 22.0%. End-to-end timings
remain dominated by Windows/WSL process startup and vary between runs.

Verification

  • cargo test --target x86_64-pc-windows-gnu -- --test-threads=1
    • 26 unit tests passed
    • 14 integration tests passed
  • cargo bench --target x86_64-pc-windows-gnu --bench benchmark -- --iterations 1
  • cargo build --release --target x86_64-pc-windows-gnu
  • cargo fmt --all -- --check
  • cargo clippy --target x86_64-pc-windows-gnu --all-targets
  • git diff --check

The nightly-only harness was not runnable in the repository's normal
Windows cross-target workflow. Use a self-contained executable harness
that fails on invalid runs and reports repeatable timing statistics.
Tests previously assumed a checkout named `wslgit` and a Bash login
shell. Derive both values from the active checkout and WSL environment
so isolated worktrees exercise the same behavior reliably.
Output path conversion launched a second WSL process after every Git
command. Convert paths directly when the active UNC distribution or
Windows drive proves the mapping, while retaining the existing fallback
for ambiguous paths and preserving non-UTF-8 output.
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.

1 participant