Skip to content

perf(cli): buffer scan stdout writes - #61

Open
mizchi wants to merge 1 commit into
moonbit-community:mainfrom
mizchi:perf/buffer-scan-stdout
Open

perf(cli): buffer scan stdout writes#61
mizchi wants to merge 1 commit into
moonbit-community:mainfrom
mizchi:perf/buffer-scan-stdout

Conversation

@mizchi

@mizchi mizchi commented Jul 30, 2026

Copy link
Copy Markdown

Summary

  • buffer scan stdout in 64 KiB chunks
  • preserve the existing per-hit writer callback used by tests
  • retain JSONL output and stderr streaming

Benchmark

Native release, 1,000 copies of matching/matching.mbt (~56,000 JSON hits):

version mean
before 2.645 s
buffered stdout 2.316 s

This is a 12.5% improvement; system time fell from 0.373 s to 0.170 s.

Validation

  • moon info && moon fmt
  • moon check
  • moon test (422 passed)
  • git diff --check

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread cli/stream_output.mbt
Comment on lines +34 to +35
if stdout.length >= 65536 {
flush_buffered_scan_stdout(stdout)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

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