Skip to content

perf: fast path for zsh rprompt - 55ms to 5ms (8x faster)#2692

Open
AasheeshLikePanner wants to merge 3 commits intoantinomyhq:mainfrom
AasheeshLikePanner:fix/2574-zsh-rprompt-perf
Open

perf: fast path for zsh rprompt - 55ms to 5ms (8x faster)#2692
AasheeshLikePanner wants to merge 3 commits intoantinomyhq:mainfrom
AasheeshLikePanner:fix/2574-zsh-rprompt-perf

Conversation

@AasheeshLikePanner
Copy link

Summary

This PR fixes the flaky zsh rprompt benchmark in #2574 by implementing an early-exit fast path for the zsh rprompt command when no conversation ID is present.

Changes

Added a fast path in main.rs that checks for zsh rprompt command BEFORE any heavy initialization:

  • If _FORGE_CONVERSATION_ID is NOT set → print static prompt and exit immediately
  • If _FORGE_CONVERSATION_ID IS set → continue with normal full initialization
    This bypasses:
  • ForgeInfra (HTTP client, gRPC, MCP, .env loading)
  • ForgeRepo (SQLite connection pool)
  • ForgeServices (20+ services)

Results

Benchmark Before After Improvement
CI (ubuntu-latest) 55ms 5ms 8x faster
Local 33ms 7ms 4.7x faster

Benchmark (CI)

avg: 5ms
p75: 6ms
threshold: 80ms
Status: PASS

Before Screenshot

image

After Screenshot

image

@CLAassistant
Copy link

CLAassistant commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Bypasses heavy initialization (ForgeInfra, ForgeRepo, ForgeServices)
when _FORGE_CONVERSATION_ID is not set.
@AasheeshLikePanner AasheeshLikePanner force-pushed the fix/2574-zsh-rprompt-perf branch from d9f1666 to 7dd2327 Compare March 25, 2026 13:16
AasheeshLikePanner and others added 2 commits March 25, 2026 18:57
- Check exact argument positions to avoid false positives
- Check BEFORE Cli::parse() to avoid parsing overhead
- Falls back to normal path when _FORGE_CONVERSATION_ID is set
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.

3 participants