Skip to content

Reduce idle Codex adapter CPU usage - #1192

Merged
edwin-zvs merged 1 commit into
mainfrom
perf/codex-transcript-watcher
Aug 3, 2026
Merged

Reduce idle Codex adapter CPU usage#1192
edwin-zvs merged 1 commit into
mainfrom
perf/codex-transcript-watcher

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

Summary

  • tail Codex root and native-child rollout JSONL files from byte offsets instead of rereading full history every 500 ms
  • cache rollout metadata after reading only the first JSONL record
  • discover new rollouts from changed directory mtimes, with a periodic full-scan safety net
  • preserve full native-child backfill, partial-write retries, truncation recovery, and /clear rebinding

Motivation

A live sample of an idle construct __adapter codex process showed CPU in recursive rollout discovery and whole-file read_to_string calls. On this machine, 28 Codex adapters consumed roughly 33–36% of one core in aggregate. The rollout store contains 2,120 files / 1.0 GB; one sampled adapter reread an 18.9 MB root transcript multiple times per second while idle.

After this change, idle root and child transcripts cost a file-length metadata check with no content read. Directory discovery normally stats the 68 rollout directories and only enumerates a directory whose entries changed; the 10-second full enumeration backstop handles coarse or coalesced timestamps.

Verification

  • cargo test -p construct-adapter-codex — 31 passed
  • cargo clippy -p construct-adapter-codex --all-targets --no-deps -- -D warnings -A clippy::too_many_arguments
  • cargo build

No screenshot or recording: this is an internal adapter performance change with no UI difference.

@edwin-zvs
edwin-zvs merged commit 90ca14f into main Aug 3, 2026
1 check passed
@edwin-zvs
edwin-zvs deleted the perf/codex-transcript-watcher branch August 3, 2026 14:34
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