Skip to content

Improvement: Enable UseCachedSize in proto marshal to eliminate redundant size computation #8570

@rs-unity

Description

@rs-unity

The proto message size is currently computed twice:

  1. Once before marshalling.
  2. Again during the marshalling call itself.

In high-throughput workloads, this duplicated computation is expensive and unnecessary.

By enabling UseCachedSize on MarshalOptions, we can reuse the size calculated immediately before marshalling, avoiding the redundant second call to proto.Size.

Impact

In our application, the extra proto.Size call accounted for ~12% of total CPU time. Removing it results in a significant performance improvement while preserving correctness.

Proposed Change

Metadata

Metadata

Assignees

Labels

Area: RPC FeaturesIncludes Compression, Encoding, Attributes/Metadata, Interceptors.Type: PerformancePerformance improvements (CPU, network, memory, etc)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions