-
Notifications
You must be signed in to change notification settings - Fork 2
Box large LoopbackEvent variants to reduce enum size #1737
Copy link
Copy link
Closed
Labels
archArchitecture and designArchitecture and designenhancementNew feature or requestNew feature or request
Description
Problem
LoopbackEvent in crates/zeph-core/src/channel.rs has variants with inline data:
ToolStart— 5 fields (String, String, Option, Option, Instant)ToolOutput— 11 fields including String, Option, Option<Vec>, etc.
Every LoopbackEvent value is sized to the largest variant (ToolOutput), which is likely 200+ bytes. Since these events flow through an mpsc channel, every smaller variant (Chunk, Flush, Status) carries this overhead.
Proposed Changes
- Extract
ToolStartData(owned) andToolOutputData(owned) structs - Box them in the enum:
ToolStart(Box<ToolStartData>),ToolOutput(Box<ToolOutputData>) - This reduces the base enum size to ~40 bytes (largest non-boxed variant)
Motivation
- Reduces memory pressure on the mpsc channel buffer
- Simplifies match arms (destructure the struct, not 11 inline fields)
- Existing borrowed
ToolStartEvent<'a>/ToolOutputEvent<'a>structs already model the same shape
Files
crates/zeph-core/src/channel.rs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
archArchitecture and designArchitecture and designenhancementNew feature or requestNew feature or request