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
86f5f12 to
7529a91
Compare
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.Bash and Zsh now start the independent virtualenv, Conda, Node version, Git, and Zsh
KUBECONFIGwork concurrently through process substitutions, then drain their outputs into caller-local variables with a sharedwarp_read_parallel_outputshelper. This avoids temporary files and remains compatible with Bash 3.2.Fish cannot run shell functions concurrently, so it uses a Fish-specific approach: an uncached Node version pipeline starts before the grouped Git lookup, then independent JSON-escaping pipelines run concurrently and write into a private per-shell directory that is removed on exit. Fish falls back to serial collection if that directory cannot be created.
Across all three shells, Git head and branch stay grouped 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 prompt-context collection with all fields non-empty:
A separate end-to-end Fish benchmark of the full
precmdhook measured cold latency improving from 58.5 ms to 47.1 ms (1.24x / 19.5% lower, +4.6% CPU) and warm latency improving from 35.3 ms to 31.7 ms (1.11x / 10.2% lower, +1.0% CPU).The collection 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. The Fish full-hook benchmark used batches of 30 collections, with 3 warmups and 20 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.shfish -n app/assets/bundled/bootstrap/fish.shKSH_ARRAYSenabled.precmdpayloads for named and detached Git HEADs with cold and warm Node caches.No new automated tests were added because this is performance-sensitive shell bootstrap behavior validated directly in all three target shells and through comparative benchmarks.
./script/runAgent Mode
CHANGELOG-NONE
Co-Authored-By: Oz oz-agent@warp.dev