Repository navigation
Box Onset in TailEvent::Event - #8281
Merged
Merged
Conversation
TailEvent::Event is a OneOf, so it is as large as its largest alternative. Onset is 416 bytes on x86-64; the next largest, SpanOpen and Exception, are 128. Every queued tail event, most of them logs, paid for an Onset that occurs once per session: sizeof(TailEvent) was 496 bytes. Hold Onset in a kj::Own instead. sizeof(TailEvent) drops to 208 bytes, which cuts the memory a streaming tail session holds for a backlog of short logs by more than half. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ Approved — Mechanical boxing of Onset is applied consistently at every use; no issues found.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
📋 Code Quality: ✅ LGTM
Every TailEvent::Event match, check and construction site now uses kj::Own<Onset>. Cloning makes a deep copy with kj::heap(onset->clone()), and the RPC read path builds the event on the heap. Behaviour does not change.
📝 Documentation: ✅ LGTM
The new comment in trace.h explains why Onset is boxed and describes the code as it is now.
Reviewed commit: 46a540d5
maxmcd
approved these changes
Nov 7, 2026
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.
TailEvent::Eventis akj::OneOf, so it is as large as its largest alternative.Onsetis 416 bytes on x86-64, while the next largest (SpanOpen,Exception) are 128. Every queued tail event, most of them logs, paid for anOnsetthat occurs once per session:sizeof(TailEvent)was 496 bytes.This holds
Onsetin akj::Owninstead.sizeof(TailEvent)drops to 208 bytes, which more than halves the memory a streaming tail session holds for a backlog of short logs.Found while investigating an edgeworker load test (
streaming-trace-perf_1000) where a tail worker falling behind let the process accumulate 7 GiB of queued tail events. #8282 (stacked on this) bounds that memory.🤖 Generated with Claude Code