openai / openai/codex

Rapid @ file-search edits replay superseded queries

Open
#40,765 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app-server bug CLI performance TUI
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What issue are you seeing?

Rapid @ file-search edits enqueue every changed query in an unbounded channel. One matcher worker consumes them in order. When repository walking or matching is slower than typing, obsolete queries still pay parse, match, snapshot, and event costs before the current query can finish.

This is separate from #33847. That issue covers repeated snapshots for one accepted query at the app-server boundary. This report covers obsolete query values before and inside the shared matcher, so it affects both the TUI and app-server.

A fixed workload showed current-query latency fall from 328.9 ms to 150.3 ms, or 54.3%, after latest-value coalescing. The paired median reduction was 179.7 ms across 10 pairs, with a 19/20 confidence interval of 173.8–184.6 ms.

What steps can reproduce the bug?
  1. Create a tree with 32,768 files.
  2. Start TUI file search while the tree is still walking.
  3. Send four bursts of 32 query prefixes at 1 ms cadence.
  4. Measure from the burst start to the result for the current query.

The source path sends each edit as WorkSignal::QueryUpdated(String) through an unbounded channel. The matcher worker handles the signals serially. A stale snapshot can then reach a client reporter before the client rejects it for not matching its current query.

A prepared change replaces queued query values with a latest-query mailbox and one wake signal. It keeps walk-complete, matcher, shutdown, and accepted-update completion signals reliable. It also filters stale snapshots before TUI and app-server delivery.

Prepared and measured branch:
https://github.com/perfloop/codex/tree/perfloop-pr-open-10zm2t4kx3

Change commit:
https://github.com/perfloop/codex/commit/271fd4c592d9dd5fd3d5325d2219ee58c4f18c3b

Benchmark commit:
https://github.com/perfloop/codex/commit/c0efda30a41ff0af5bb3b2b4830e3e37618777db

What is the expected behavior?

File search may skip intermediate query values. It must process the latest value, preserve final results, and keep session completion reliable. Obsolete query values must not delay the current result.

Additional information

The prepared change passed formatting, locked tests for codex-file-search, TUI file search, and app-server fuzzy file search, the benchmark smoke test, Clippy with warnings denied, and the Bazel end-to-end smoke test. Eight checks passed.

Full evidence: https://app.perfloop.ai/t/oss/case_c7zssat97s

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the shared matcher entry point handling WorkSignal::QueryUpdated(String), then inspect the TUI and app-server file-search delivery paths. Run the codex-file-search, TUI file-search, app-server fuzzy file-search, benchmark smoke, and Bazel smoke checks. Done means intermediate queries may be skipped, the latest query finishes promptly with final results, and completion signals remain reliable.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, search
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.