Skip to content

perf(monitors): count streamed line bytes once - #120

Merged
vincentkoc merged 1 commit into
mainfrom
perf/monitor-line-bytes
Nov 20, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
perf/monitor-line-bytes

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

Claude monitor output can arrive in small chunks. Measuring the entire unfinished line for every chunk repeatedly scanned the same text. The reader now counts each decoded fragment once and resets the byte count at each line break.

Compatibility

The reader still uses UTF-8 decoding, counts the decoder's final replacement character, retains complete preceding lines, and stops the monitor once a line exceeds 1 MiB. The queue limits, process supervision and monitor permissions are unchanged.

Verification

  • The boundary test streams a full 1 MiB line in fragments, completes it, then overflows the next line only when an incomplete character is flushed.
  • On Node 24.22.1, feeding one 1 MiB ASCII line in 256-byte chunks took 477 ms before and 1.3 ms after (medians of three local samples).
  • npm run check and the offline npm run pack:check passed, including installed CLI, runtime, MCP, declaration and rollback checks.

@clawsweeper

clawsweeper Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@vincentkoc
vincentkoc marked this pull request as ready for review November 20, 2026 15:57
@vincentkoc
vincentkoc merged commit f022971 into main Nov 20, 2026
11 checks passed
@vincentkoc
vincentkoc deleted the perf/monitor-line-bytes branch November 20, 2026 16:01
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