perf(cli): buffer scan stdout writes - #61
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fa596cefe3
ℹ️ 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 stdout.length >= 65536 { | ||
| flush_buffered_scan_stdout(stdout) |
There was a problem hiding this comment.
Flush sparse matches while scanning
When fewer than 64 KiB of matches have accumulated, this condition withholds every result until the entire traversal finishes. Thus an early match followed by a long scan produces no observable stdout for a pager or JSONL consumer, regressing the documented behavior that moongrep outputs results directly as it scans (SKILL.md:23-28) and the function's own streaming contract. Retain batching for throughput, but add a time-/idle-based flush or otherwise ensure sparse results become visible before completion.
Useful? React with 👍 / 👎.
Summary
Benchmark
Native release, 1,000 copies of
matching/matching.mbt(~56,000 JSON hits):This is a 12.5% improvement; system time fell from 0.373 s to 0.170 s.
Validation
moon info && moon fmtmoon checkmoon test(422 passed)git diff --check