Skip to content

perf: remove remaining hot-path bottlenecks across tools, TUI, and syntax - #282

Merged
github-actions[bot] merged 1 commit into
mainfrom
perf/agent-loop-render-hotpaths
Aug 6, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
perf/agent-loop-render-hotpaths

Conversation

@mohitranka

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #281: removes the remaining hot-path costs identified in the performance review. Nine focused fixes, one per crate area.

Changes

forge-tools

  • In-process unified diff via similar (Myers), replacing the git diff --no-index subprocess + two temp-file writes per write_file/apply_patch call
  • Build fff WorkspaceIndex outside the cache mutex (cold-cache scan of a large workspace was serializing every concurrent find/grep) and enable watch so tool results track files the agent itself writes
  • Rolling-hash hunk matching in apply_patch: per-hunk O(N*M) string compares -> O(N), with exact string verify on candidates

forge-syntax

  • Highlight cache: hash-bucketed map with exact full-key verify; hit path allocates zero strings (previously cloned the whole source block per lookup)
  • JSON content detection: gate the full serde parse behind a 256 KiB size cap (the parse allocated the value tree every render, even on cached highlights)
  • Quick-open subsequence scorer: exact dominance memo + remaining-length bound, exponential -> O(N*M) worst case

forge-core

  • Memoize token estimates behind a messages.len() dirty check

forge-durable

  • SQLite WAL journal + synchronous=NORMAL for the session store

forge-tui

  • Throttle streaming live-preview renders to 150 ms

Validation

  • cargo fmt --all -- --check clean
  • cargo clippy --workspace --all-targets --locked -- -D warnings clean
  • Full workspace test run green except two failures confirmed pre-existing on base (env-dependent forge-config permissions tests reading real config; a flaky forge-connect localhost mock that passes on retry)
  • cargo build --release --locked --package forge-cli + forge --version OK

…ntax

- tools: in-process unified diff via similar, dropping the git-diff subprocess
  and temp files per write_file/apply_patch call
- tools: build fff indexes outside the cache mutex and watch live so tool
  results track agent-written files
- tools: rolling-hash hunk matching in apply_patch (O(N*M) -> O(N) per hunk)
- syntax: hash-bucket highlight cache with zero string allocation on hit
- syntax: bound JSON content-detection parse so huge brace blocks skip it
- syntax: exact dominance memo bounds quick-open subsequence search
- core: memoize token estimates behind a messages.len() dirty check
- durable: SQLite WAL journal + synchronous NORMAL
- tui: throttle streaming live-preview renders to 150ms
@github-actions
github-actions Bot enabled auto-merge (squash) August 6, 2026 04:14
@github-actions
github-actions Bot merged commit ffadc8d into main Aug 6, 2026
7 checks passed
mohitranka added a commit that referenced this pull request Aug 21, 2026
…ntax (#282)

- tools: in-process unified diff via similar, dropping the git-diff subprocess
  and temp files per write_file/apply_patch call
- tools: build fff indexes outside the cache mutex and watch live so tool
  results track agent-written files
- tools: rolling-hash hunk matching in apply_patch (O(N*M) -> O(N) per hunk)
- syntax: hash-bucket highlight cache with zero string allocation on hit
- syntax: bound JSON content-detection parse so huge brace blocks skip it
- syntax: exact dominance memo bounds quick-open subsequence search
- core: memoize token estimates behind a messages.len() dirty check
- durable: SQLite WAL journal + synchronous NORMAL
- tui: throttle streaming live-preview renders to 150ms
mohitranka added a commit that referenced this pull request Sep 11, 2026
…ntax (#282)

- tools: in-process unified diff via similar, dropping the git-diff subprocess
  and temp files per write_file/apply_patch call
- tools: build fff indexes outside the cache mutex and watch live so tool
  results track agent-written files
- tools: rolling-hash hunk matching in apply_patch (O(N*M) -> O(N) per hunk)
- syntax: hash-bucket highlight cache with zero string allocation on hit
- syntax: bound JSON content-detection parse so huge brace blocks skip it
- syntax: exact dominance memo bounds quick-open subsequence search
- core: memoize token estimates behind a messages.len() dirty check
- durable: SQLite WAL journal + synchronous NORMAL
- tui: throttle streaming live-preview renders to 150ms
mohitranka added a commit that referenced this pull request Sep 11, 2026
…ntax (#282)

- tools: in-process unified diff via similar, dropping the git-diff subprocess
  and temp files per write_file/apply_patch call
- tools: build fff indexes outside the cache mutex and watch live so tool
  results track agent-written files
- tools: rolling-hash hunk matching in apply_patch (O(N*M) -> O(N) per hunk)
- syntax: hash-bucket highlight cache with zero string allocation on hit
- syntax: bound JSON content-detection parse so huge brace blocks skip it
- syntax: exact dominance memo bounds quick-open subsequence search
- core: memoize token estimates behind a messages.len() dirty check
- durable: SQLite WAL journal + synchronous NORMAL
- tui: throttle streaming live-preview renders to 150ms
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