Skip to content

perf(shell-integration): emit prompt marks in one write via kitty-shell-cwd://#19

Merged
simota merged 1 commit into
mainfrom
perf/shell-integration-prompt-hooks
Jul 16, 2026
Merged

perf(shell-integration): emit prompt marks in one write via kitty-shell-cwd://#19
simota merged 1 commit into
mainfrom
perf/shell-integration-prompt-hooks

Conversation

@simota

@simota simota commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Summary

cmd.overhead (zsh) が ghostty 比 +25% だった真因の修正。zsh の precmd フックが $PWD を1文字ずつ percent-encode(非ASCII文字ごとに $(printf) を fork)し、プロンプト毎に printf を4回発行していた。fish はプロンプト毎に (hostname) を fork していた。

  • OSC 7 を Ghostty/kitty と同じ kitty-shell-cwd://(raw path・エンコード不要、パーサは REQ-OSC-3 で対応済み)に変更
  • zsh/bash/fish とも D/7/A/B を単一 builtin printf に統合 → 60µs → 7µs/prompt(非ASCIIパスでは 3.7ms → 7µs)
  • ZDOTDIR leak 修正: ユーザ未設定なら起動後に unset(Ghostty parity。従来は ZDOTDIR=$HOME が export されたまま残り、セッション内の子シェル計測を汚染)。USER_ZDOTDIR も非 export 化

Test plan

  • cargo test -p noa-pty 35/35 pass(zsh/bash 実 pty の OSC 133/7 E2E 含む・新スキームに追随)
  • cargo clippy --workspace クリーン
  • 手動検証: ZDOTDIR 復元/unset・フック登録・OSC バイト列を zsh/bash 実プロセスで確認。isolated HOME の hyperfine で起動コスト非退行(Noa統合 +0.5ms vs Ghostty +1.4ms)
  • fish は未インストールのため実プロセス未検証(構文は zsh/bash と同型)

…ll-cwd://

The zsh precmd hook percent-encoded $PWD one character at a time,
forking $(printf) for every non-ASCII character (~60µs/prompt on an
ASCII path, ~3.7ms in a non-ASCII path), and each hook issued four
separate printf writes. The fish hook forked (hostname) on every
prompt.

Switch OSC 7 to the kitty-shell-cwd:// scheme (raw path, no encoding —
the parser already supports it per REQ-OSC-3) and emit D/7/A/B as a
single builtin printf in zsh/bash/fish: ~7µs/prompt regardless of path
content.

Also stop leaking noa-only bookkeeping into the session environment:
ZDOTDIR is now unset after startup when the user never had one
(Ghostty parity; previously ZDOTDIR=$HOME stayed exported), and
USER_ZDOTDIR is a plain unexported variable.
@simota
simota merged commit 23b02b5 into main Jul 16, 2026
1 check passed
@simota
simota deleted the perf/shell-integration-prompt-hooks branch July 16, 2026 12:54
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