-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Labels
Area: RPC FeaturesIncludes Compression, Encoding, Attributes/Metadata, Interceptors.Includes Compression, Encoding, Attributes/Metadata, Interceptors.Type: PerformancePerformance improvements (CPU, network, memory, etc)Performance improvements (CPU, network, memory, etc)
Description
The proto message size is currently computed twice:
- Once before marshalling.
- 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
- Enable
UseCachedSizeinMarshalOptionsto eliminate duplicate size calculations. See encoding/proto: enable use cached size option #8569
Metadata
Metadata
Assignees
Labels
Area: RPC FeaturesIncludes Compression, Encoding, Attributes/Metadata, Interceptors.Includes Compression, Encoding, Attributes/Metadata, Interceptors.Type: PerformancePerformance improvements (CPU, network, memory, etc)Performance improvements (CPU, network, memory, etc)