Parallelize work done by the shell for the precmd hook.#12869
Draft
vorporeal wants to merge 2 commits into
Draft
Parallelize work done by the shell for the precmd hook.#12869vorporeal wants to merge 2 commits into
vorporeal wants to merge 2 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
precmdpreviously 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
KUBECONFIGwork concurrently through process substitutions, then drains their outputs into caller-local variables with a sharedwarp_read_parallel_outputshelper. 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:
The benchmark ran from a package-containing checkout with a real
.gitdirectory, 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.shKSH_ARRAYSenabled.No new automated tests were added because this is performance-sensitive shell bootstrap behavior validated directly in both target shells and through comparative benchmarks.
./script/runAgent Mode
CHANGELOG-NONE
Co-Authored-By: Oz oz-agent@warp.dev