Rapid @ file-search edits replay superseded queries

Open 💬 0 comments Opened Aug 26, 2026 by tsenart

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

View original on GitHub ↗