Skip to content

perf: fix runtime bottlenecks across model, tools, core, and TUI - #281

Merged
github-actions[bot] merged 6 commits into
mainfrom
perf/fix-runtime-bottlenecks
Aug 6, 2026
Merged

github-actions[bot] merged 6 commits into
mainfrom
perf/fix-runtime-bottlenecks

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

Reduces per-frame render cost and tool-call overhead across the agent runtime.

Changes

Model streaming (785ece2)

  • Replace busy-polling stream relay with async tokio::mpsc
  • SSE parsing: cursor-based line processor, no quadratic front-draining

MCP/connect (fbdce41)

  • Serialize MCP requests, null stderr, add 10s timeouts
  • HTTP timeouts on connect providers

Tools (04616e8)

  • Cache compiled JSON Schema validators per tool (was recompiled per call)
  • Bound captured command output at 512 KiB; stream file reads via BufReader
  • Offload file index/search to spawn_blocking; truncate unified session output at 1 MiB

Core (c566c3a)

  • Index evidence by operation for tool completions
  • Cap terminal task retention at 64; compact terminal queue

Context (a56eb1a)

  • Cache skill manifests; refresh_skills() invalidates explicitly

TUI (8f3b4bf)

  • Cache diff/stream rendering so steady-state frame cost is the viewport, not the transcript
  • Bound/coalesce run output; drop redundant shell redraws; cache progress.json by mtime
  • Reuse visible file-explorer nodes; linear KMP source search

Benchmark (120x40, 150 turns)

before after
p50 frame 8.9 ms ~8.3 ms
allocs/frame 3,594 ~2,853
KiB/frame 956 ~717

Validation

  • cargo fmt --all -- --check, cargo clippy --workspace --all-targets --locked -- -D warnings, git diff --check pass
  • Focused tests: forge-core 143, forge-tools 159, forge-tui 727, forge-model 50, forge-mcp 9, forge-context 22, forge-connect 185, forge-cli 11

Compile JSON schema validators once per tool and share via Arc instead of
recompiling on every call. Bound captured command output to 512 KiB and
stream file reads through BufReader. Offload file index/search to
spawn_blocking. Truncate unified session output at 1 MiB.
Index evidence by operation in a HashMap for tool completion lookups.
Cap terminal task retention at 64 and compact terminal queue items on
append, so long sessions stop growing allocation history.
Parse skill manifests once per session instead of re-reading on every
lookup; refresh_skills invalidates the cache explicitly.
Cache diff computation by revision and stream lines by hash so steady-state
frames cost the viewport, not the transcript. Cap and coalesce run output,
skip redundant shell redraws, cache progress.json by mtime, and reuse
visible file-explorer nodes. Replace quadratic source search with linear
KMP matching.
@github-actions
github-actions Bot enabled auto-merge (squash) August 6, 2026 03:29
@github-actions
github-actions Bot merged commit 9d13ab5 into main Aug 6, 2026
7 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
* perf: harden MCP and connect latency

* perf: reduce model streaming overhead

* perf(tools): cache validators and bound command output

Compile JSON schema validators once per tool and share via Arc instead of
recompiling on every call. Bound captured command output to 512 KiB and
stream file reads through BufReader. Offload file index/search to
spawn_blocking. Truncate unified session output at 1 MiB.

* perf(core): index evidence and bound terminal history

Index evidence by operation in a HashMap for tool completion lookups.
Cap terminal task retention at 64 and compact terminal queue items on
append, so long sessions stop growing allocation history.

* perf(context): cache skill manifests

Parse skill manifests once per session instead of re-reading on every
lookup; refresh_skills invalidates the cache explicitly.

* perf(tui): cache diff/stream rendering and cap output

Cache diff computation by revision and stream lines by hash so steady-state
frames cost the viewport, not the transcript. Cap and coalesce run output,
skip redundant shell redraws, cache progress.json by mtime, and reuse
visible file-explorer nodes. Replace quadratic source search with linear
KMP matching.
mohitranka added a commit that referenced this pull request Sep 11, 2026
* perf: harden MCP and connect latency

* perf: reduce model streaming overhead

* perf(tools): cache validators and bound command output

Compile JSON schema validators once per tool and share via Arc instead of
recompiling on every call. Bound captured command output to 512 KiB and
stream file reads through BufReader. Offload file index/search to
spawn_blocking. Truncate unified session output at 1 MiB.

* perf(core): index evidence and bound terminal history

Index evidence by operation in a HashMap for tool completion lookups.
Cap terminal task retention at 64 and compact terminal queue items on
append, so long sessions stop growing allocation history.

* perf(context): cache skill manifests

Parse skill manifests once per session instead of re-reading on every
lookup; refresh_skills invalidates the cache explicitly.

* perf(tui): cache diff/stream rendering and cap output

Cache diff computation by revision and stream lines by hash so steady-state
frames cost the viewport, not the transcript. Cap and coalesce run output,
skip redundant shell redraws, cache progress.json by mtime, and reuse
visible file-explorer nodes. Replace quadratic source search with linear
KMP matching.
mohitranka added a commit that referenced this pull request Sep 11, 2026
* perf: harden MCP and connect latency

* perf: reduce model streaming overhead

* perf(tools): cache validators and bound command output

Compile JSON schema validators once per tool and share via Arc instead of
recompiling on every call. Bound captured command output to 512 KiB and
stream file reads through BufReader. Offload file index/search to
spawn_blocking. Truncate unified session output at 1 MiB.

* perf(core): index evidence and bound terminal history

Index evidence by operation in a HashMap for tool completion lookups.
Cap terminal task retention at 64 and compact terminal queue items on
append, so long sessions stop growing allocation history.

* perf(context): cache skill manifests

Parse skill manifests once per session instead of re-reading on every
lookup; refresh_skills invalidates the cache explicitly.

* perf(tui): cache diff/stream rendering and cap output

Cache diff computation by revision and stream lines by hash so steady-state
frames cost the viewport, not the transcript. Cap and coalesce run output,
skip redundant shell redraws, cache progress.json by mtime, and reuse
visible file-explorer nodes. Replace quadratic source search with linear
KMP matching.
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