While investigating Temporal Rust SDK issue #1653, I measured an enum that occupied 624 bytes inline. Boxing every variant brought a mirror of it down to 16 bytes.
That was an attractive number. It was also far from enough evidence to call the change a performance improvement.
The investigation became draft PR #1781. It contains a descriptor-driven boxing experiment and a runnable allocation probe. As of November 16, 2026, it remains open and incomplete. Here is what the measurements actually establish.
The handwritten enum, UpdateMsg, carries three generated protobuf message types: Acceptance, Rejection, and Response. My initial measurements used Rust 1.95.0 on aarch64-apple-darwin:
| Representation | Inline bytes |
|---|---|
| Original enum mirror | 624 |
Only Rejection boxed | 352 |
| All three variants boxed | 16 |
These are size_of results for that compiler, target, and resolved dependencies. They are not stable Rust ABI promises.
The enum needs enough inline space for its largest variant. Boxing the 624-byte Rejection removes that large inline value, but leaves the 352-byte Response. Boxing every variant leaves pointers and the enum's discriminant.
The missing part of the 16-byte result is the pointee. With every variant boxed, an acceptance needs a 320-byte heap object, a rejection 624 bytes, and a response 352 bytes. Adding the 16-byte enum gives nominal live storage of 336, 640, or 368 bytes respectively, before allocator overhead and separately allocated contents.
A rejection can therefore occupy more nominal storage than the original 624-byte enum slot. The smaller slot may still matter in some contexts, but the allocation has not disappeared. Neither have the backing allocations of strings, vectors, and maps; size_of does not include their contents.
Next I investigated selecting boxes from protobuf descriptors instead of maintaining a field-name list. This is a different experiment from manually boxing enum variants.
An early selector considered large message-valued oneof arms. It shrank Outcome from 304 to 24 bytes but left the UpdateMsg mirror at 624. The large rejection contained ordinary singular message fields, so optimizing only oneof arms did not remove the controlling size.
The later experiment also considers ordinary fields when the enclosing message exceeds a budget. Its approximate model uses estimated field sizes, minimum estimated savings, and an enclosing-message budget. The thresholds are experimental choices, not tuned defaults or an exact Rust layout model.
In the full protos pipeline, that version reduced the unchanged UpdateMsg mirror from 624 to 328 inline bytes. That result must stay separate from the manual 624-to-352 and 624-to-16 comparisons: each changes a different representation.
The public investigation document records those distinctions and the reproduction commands.
To look beyond layout, the standalone probe generates baseline and selected types from the same real proto import closure. It checks wire equality for four populated branches and measures construction plus Any encoding separately from decoding.
In those samples, rejection and failed-response paths gained an allocation; acceptance and successful-response paths did not. The measured allocation belongs to a selected field inside the generated structure. It is not the same operation as allocating an entire 624-byte Rejection in the initial manual experiment.
Even those allocation counts do not tell me the production outcome. I do not have production branch frequencies, payload distributions, replay measurements, or peak-memory data. A synthetic frequency table can show sensitivity to assumptions; it cannot supply the missing workload.
There was another important correction to the original intuition: Core immediately serializes UpdateMsg. Its outbox contains encoded protocol messages with Any bytes. A smaller temporary enum does not establish that the resident queue becomes smaller. That would require measuring the representation the queue actually holds.
Compatibility also remains work. Boxing changes generated Rust field types, which changes construction and conversion code. Focused checks and sample round trips passed, but the recorded all-feature lint attempt still had 45 Core type/conversion errors. Full workspace, server integration, and cross-platform validation remain incomplete.
The probe README also distinguishes its generation settings from the full SDK pipeline. A passing standalone experiment cannot substitute for those unfinished checks.
I can report a smaller inline representation and sample-specific allocation costs. I cannot yet report a runtime win. The next decision is about which generated API changes are acceptable and which real workload to measure—not how prominently to display the 16-byte number.

