Skip to content

[perf][P1] $(...) inside PS1 renders ~100x slower than the same call in PROMPT_COMMAND - four oh-my-bash themes hit 10x rr budget on CI #604

Closed

Description

@caomengxuan666

Evidence (ablation, three machines, same ordering)

Replay per the v1.4.0 perfbudget gate (run 38462805309 + local): omb themes axin/clean/simple/sexy embed $(scm_prompt_info)-style command substitutions directly in PS1. Their rerender (rr) medians: 336-1566ms vs 35-60ms for rr-healthy themes in the same class — 10x over the 120ms class budget, 5x over the hard-fail line.

Ablation (axin, pristine master, N=3, pins unchanged): pristine rr 1566ms; removing the embedded $(scm_prompt_info) from PS1 → 110ms (−93%); removing $(date) → 1575ms (no change); removing venv probe → 1587ms (no change). The substitution itself is the cost.

The 100x split: the same call placed in PROMPT_COMMAND runs 20-75ms on the same machines — so this is not just Windows spawn floor (#375 family, ~40ms). Two compounding halves:

  1. Per-render spawn: PS1-embedded $(...) re-forks on EVERY rerender, PROMPT_COMMAND runs it once per prompt cycle in-process context.
  2. Engine path gap (rubash-fixable): command substitution reached through the prompt-string expansion path is 7-20x slower than the same call via PROMPT_COMMAND (544-1566ms vs 20-75ms in-process) — the expansion path is leaving something on the table (state re-init, missing fast path, or per-call setup that PROMPT_COMMAND doesn't pay).

Fix directions (fix-lane, one change converges all four themes)

  • Profile the prompt-expansion path's command substitution vs the PROMPT_COMMAND path; close the 7-20x in-engine gap.
  • Consider a guarded cache for idempotent-ish prompt substitutions ONLY if semantically safe (git-status caching has staleness semantics — needs owner ruling).

Impact

omb axin/clean/simple/sexy + bashit sexy/font/sirup rr budgets currently need 1200-2600ms overrides (recorded in scripts/perf/budgets.toml with ablation data). Fixing the engine path lets the overrides drop back to class-normal.

Data cross-refs: niubash scripts/perf/budgets.toml overrides + justifications (v1.4.0 release gate), CI run 38462805309 timing log.

Activity

  1. added
    performance
    on Oct 13, 2026
  2. added a commit that references this issue on Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    performance

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions