perf(shared): buffer fragmented local data-plane lines - #402
Open
slashdevcorpse wants to merge 1 commit into
Open
perf(shared): buffer fragmented local data-plane lines#402slashdevcorpse wants to merge 1 commit into
slashdevcorpse wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Refs #240
Problem / pressure
The local data-plane JSON line splitter concatenates and searches the entire pending line on every socket chunk. Large fragmented frames repeatedly scan and flatten the same prefix. Both Electron and the CLI use this shared splitter.
Summary
Keep decoded fragments and their character count until a newline arrives, then join once. Complete lines within one chunk still use direct slices. Preserve the decoder, trimming, overflow recovery, and unread input after a callback exception.
This is the isolated chunk-buffering slice of #240. The current implementation lives in
packages/shared/src/local-loro-data-plane.ts, consumed by the Electron relay and CLI server. It does not alter RPC transport, renderer rows, usage queries, wire formats, or dependencies. The remaining issue scope stays open.Before / after
Synthetic splitter benchmark on Windows, Node 24.15.0, pnpm 10.20.0, Vitest 3.2.4. Values are mean milliseconds per operation, with fixture creation and full-output verification outside timing.
The baseline is
d0e5059. The same benchmark ran before and after the source change. The slowest baseline had three samples; these are microbenchmark means, not application p95 measurements. No renderer heap, FPS, thread-open, or compression improvement is claimed.Test plan
corepack pnpm --filter @lody/shared exec vitest bench --run local-loro-data-plane-splitterpassed before and after the change. The committed benchmark verifies complete output and can be rerun without timing thresholds.corepack pnpm --filter @lody/shared typecheckpassed.corepack pnpm --filter lody test local-loro-data-plane-bug-repro --maxWorkers=2passed the real socket overflow/recovery regression.node --test apps/electron/src/main/services/loro-data-plane-relay.test.mjspassed.git diff --check, andnode scripts/check-public-boundary.mjspassed.corepack pnpm checkdid not pass. Lint reported zero errors; the shared suite passed 1,010 tests but failed the daemon shutdown callback assertion inlocal-cli-host-lease.test.ts:133. The root typecheck command also reported no projects matching its recursive filters, so shared typecheck was run directly.d0e5059. The host-lease test and implementation match baseline byte-for-byte, but its baseline run could not resolve Vitest in the dependency-free clone. These areas are outside this PR. Full desktop interaction and application-level profiling were not run.Context handoff
Instructions for reviewing agents
packages/shared/src/local-loro-data-plane.ts.Authoring context