You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by "seekskyworld (via GitHub)" <gi...@apache.org> on 2026/09/15 16:11:15 UTC

[I] perf(runtime-host): avoid repeated prefix copies and scans for fragmented frames [maka]

seekskyworld opened a new issue, #5355:
URL: https://github.com/apache/maka/issues/5355

   ### Problem
   
   The Runtime Host byte-stream transport repeatedly copies and scans an incomplete Local IPC frame on every input fragment. `#receive()` concatenates the entire retained prefix, while `#drainInbound()` and `#updateReadFlow()` search it again from byte zero. For a fixed fragment size, work grows quadratically with frame length despite the 768 KiB frame limit.
   
   This is in the actual `FramedTransport` receive path, before `LocalIpcProtocolFrameDecoder`. Optimizing only the decoder would miss it because the transport normally feeds that decoder complete frames.
   
   On source commit `e13656ef3`, a deterministic transport test feeding a 192 KiB JSON payload in 256-byte fragments observes **75,792,143 copied bytes for 196,623 input bytes**. The payload still arrives correctly; the problem is wasted work on the Host event loop.
   
   ### Desired outcome
   
   Keep fragmented-frame copying and delimiter search linear in received bytes, while retaining owned input bytes, strict UTF-8 validation, frame/queue byte limits, backpressure, and half-open/partial EOF behavior. Reuse the existing frame decoder and wire representation.
   
   A local implementation grows the receive allocation geometrically (capped at the existing 2 MiB input buffer limit), remembers the delimiter search position, and drops the allocation when drained.
   
   Same-load loopback TCP experiment on macOS arm64 / Node v26.4.0, 512-byte writes with an event-loop yield between writes; 9 warm samples per size after one instrumented sample:
   
   | JSON payload | Before median / p95 | After median / p95 | Before / after counted copy bytes |
   | --- | --- | --- | --- |
   | 64 KiB | 3.77 / 4.46 ms | 1.77 / 2.11 ms | 4,219,919 / 195,599 |
   | 512 KiB | 30.61 / 31.70 ms | 13.70 / 15.97 ms | 255,595,023 / 1,572,367 |
   
   These are synthetic local transport measurements, not production latency claims. Counted `Buffer.indexOf` search ranges for 512 KiB drop from 511,191,070 to 1,048,606 bytes; these are scan upper bounds, not CPU instruction counts. Timing includes socket delivery and JSON decoding. TCP can coalesce writes.
   
   ### Alternatives or workarounds
   
   Sending larger chunks can reduce the cost but cannot guarantee how a byte stream fragments data. Increasing frame limits makes the repeated work worse. A full transport rewrite is unnecessary.
   
   Related context: #5038 tracks protocol/storage amplification; this is a separate receive-fragmentation slice from its page-encoding work. No open PR touches this transport file at the audit baseline.
   
   Automated report by OpenAI Codex on behalf of the contributor. A local fix and regression test are available; full Runtime Host validation is in progress.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [I] perf(runtime-host): avoid repeated prefix copies and scans for fragmented frames [maka]

Posted by "seekskyworld (via GitHub)" <gi...@apache.org>.
seekskyworld commented on issue #5355:
URL: https://github.com/apache/maka/issues/5355#issuecomment-5683759019

   take


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org


Re: [I] perf(runtime-host): avoid repeated prefix copies and scans for fragmented frames [maka]

Posted by "Astro-Han (via GitHub)" <gi...@apache.org>.
Astro-Han closed issue #5355: perf(runtime-host): avoid repeated prefix copies and scans for fragmented frames
URL: https://github.com/apache/maka/issues/5355


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org