Repository navigation
fix(search): bound rg JSON and context memory without hiding partial results - #46
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
6c28220 to
1116376
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c282209eb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (retainedBytes + hitBytes + beforeBytes > maxRetainedBytes) { | ||
| return { | ||
| stop: true, | ||
| warning: `retained-budget-exceeded: retained output exceeded limit of ${maxRetainedBytes} bytes`, | ||
| }; |
There was a problem hiding this comment.
Enforce the retained budget after normalization merges
When a non-ASCII query or glob has distinct NFC/NFD forms, src/host/search.js runs two to four content searches and unions their rows in mergeRows; this check therefore permits each component result to retain up to 4 MiB independently. The final guest-bound result can consequently reach 8–16 MiB while still reporting complete: true and no warning—for example, disjoint composed/decomposed matches produce a 4.45 MiB serialized result despite the documented 4 MiB content-result limit. Apply the retained-byte budget to the merged result as well so normalization cannot bypass the memory bound.
Useful? React with 👍 / 👎.
Summary
Fixes #45.
Bound content/count search data before it can overwhelm the host-to-guest transfer or the guest's 128 MiB worker:
partialandcomplete:false; early output/result stops also settruncated:true, includingsearch.count.Triage / design decisions
--max-columnsand--only-matchingdo not reduce its payload. A post-parse slice alone is too late.maxFilesizeor ignore exclusions: those would change the requested corpus and could turn a safety fix into a misleading absence claim.search.fileskeeps its existing uncapped stream-byte policy; this change targets content/count JSON.--countparser is deferred: it needs dedicated framing for newline-containing filenames and contract tests, not a drop-in--count-matchessemantic change.Verification
npm run structure:checkpassed.max:80, ignored/hidden/excluded files included) through the modified runner and real guest worker: ok:true, 26 rows,complete:false,truncated:true, budget warnings; no OOM. The corpus is private and mutable, not committed or used as a portable benchmark.Corrections to earlier issue analysis
The visible failure was a guest worker OOM. Host JSON parsing and retained matches contribute to size, but the original report did not isolate the precise peak-allocation stage. This PR tests the worker boundary instead of claiming host parsing alone explains it. Also, the current public hit schema already drops rg
submatches; it does not expose the offset invariant discussed upstream. We skip oversized records instead of attempting to rewrite them.References: BurntSushi/ripgrep#1451 and BurntSushi/ripgrep#2821.