Share exec output bytes across event history, broadcast, and replay
What variant of Codex are you using?
CLI
What feature would you like to see?
I found a potential performance concern in the current exec-server source rather than a confirmed user-visible bug.
Please preserve the existing event-history, live-broadcast, and replay behavior while allowing immutable process-output bytes to be shared between those owners instead of deeply copied. This could use a shared byte representation or shared internal event storage while retaining the current public protocol semantics.
Additional information
Evidence
- At audited upstream commit
5157493,ByteChunkowns its payload asVec<u8>, andProcessOutputChunkembeds that owned buffer. ExecProcessEventLog::publishdeeply clones every output event into replay history before moving the original event into the Tokio broadcast channel.ExecProcessEventLog::subscribeclones every retained replay event into a new subscriber-owned queue while the history lock is held.- PR #30273 made pushed process events the normal remote-exec completion path, so this code is reachable for ordinary streamed stdout and stderr.
- PR #31576 bounded retained process-event state by event count and bytes but did not change the deep-copy ownership model.
Impact
Not measured. Allocation throughput, retained-memory overhead, lock-hold duration, and end-to-end exec latency are unknown.
The source establishes one full payload copy for every published output event and another copy of retained output whenever a subscriber is created. Retention limits bound the simultaneously stored history, but they do not eliminate allocation proportional to streamed output over a process lifetime. This report does not claim a measured user-visible slowdown.
Question
Would maintainers prefer sharing immutable output bytes inside ByteChunk, or sharing internal ExecProcessEvent storage across history, broadcast, and replay while converting to the existing owned protocol representation only at required boundaries?
I checked all relevant issues, comments, pull requests, discussions, and release notes; this report is not a duplicate.
I am reporting this finding only and am not proposing a pull request unless a maintainer invites one.
Disclosure
Investigated thoroughly with GPT-5.6 Sol (runtime-default reasoning effort), using Oh My Pi as the agent framework.
This report is not generic or unreviewed AI-generated output. Its claims were checked against the cited evidence, and it includes the relevant detail intended to help maintainers resolve the issue.
If reports like this are not useful to the project, please let me know and I will refrain from submitting similar ones. My intent is to help without wasting maintainer time or energy or discouraging their work.
Thank you for your work.