Menu

What size_of could not tell me about a protobuf optimization
📰

What size_of could not tell me about a protobuf optimization

DEV Community: rust·byhashdong·about 20 hours ago
#ppuIMyJl
#devtorust#devto#dev#enum#bytes
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.