Skip to content

Parallelize work done by the shell for the precmd hook.#12869

Draft
vorporeal wants to merge 2 commits into
masterfrom
david/parallelize-precmd-work
Draft

Parallelize work done by the shell for the precmd hook.#12869
vorporeal wants to merge 2 commits into
masterfrom
david/parallelize-precmd-work

Conversation

@vorporeal

@vorporeal vorporeal commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Description

precmd previously collected and JSON-escaped each prompt-context field serially, adding the latency of every independent operation before the next prompt could render.

This change starts the independent virtualenv, Conda, Node version, Git, and Zsh KUBECONFIG work concurrently through process substitutions, then drains their outputs into caller-local variables with a shared warp_read_parallel_outputs helper. This avoids temporary files and remains compatible with Bash 3.2. Git head and branch stay grouped in one worker to avoid duplicate Git commands, while the Node eligibility directory walk and cache updates remain in the parent shell so cache state persists across prompts. Benchmarking the directory walk inside the Node worker showed no measurable benefit, so it remains serial. The MSYS2-specific Bash path is unchanged.

Performance

Measured against the original serial implementation with all prompt-context values non-empty:

Shell Node cache Serial Parallel Speedup CPU overhead
Bash 3.2 Cold 62.4 ms 34.9 ms 1.79x (44% lower latency) +7%
Bash 3.2 Warm 32.1 ms 23.0 ms 1.39x (28% lower latency) +13%
Zsh 5.9 Cold 55.7 ms 29.7 ms 1.88x (47% lower latency) +12%
Zsh 5.9 Warm 29.1 ms 17.3 ms 1.68x (40% lower latency) +14%

The benchmark ran from a package-containing checkout with a real .git directory, using Node v22.13.1 and Hyperfine. Each result is the per-hook mean from batches of 20 collections, with 5 warmups and 25–30 measured runs. CPU overhead is combined user and system time relative to the serial baseline.

Linked Issue

N/A

Testing

  • /bin/bash -n app/assets/bundled/bootstrap/bash_body.sh
  • /bin/zsh -n app/assets/bundled/bootstrap/zsh_body.sh
  • Parsed generated/minified Bash and Zsh bootstrap forms.
  • Verified caller-local output assignment on Bash 3.2 and Zsh 5.9, including Git-value splitting with Zsh KSH_ARRAYS enabled.
  • Ran the Hyperfine benchmarks documented above.

No new automated tests were added because this is performance-sensitive shell bootstrap behavior validated directly in both target shells and through comparative benchmarks.

  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-NONE

Co-Authored-By: Oz oz-agent@warp.dev

@cla-bot cla-bot Bot added the cla-signed label Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant