Please sign in to comment.
Optimize `ProtoBufSerializationProvider` by minimizing copying (#943)
Motivation: Current implementation of `ProtoBufSerializationProvider` has a few performance issues: 1. `ProtoDeserializer` may create an intermediate copy of the composite buffers and then copy it again inside proto parser. 2. `DefaultSerializer.DEFAULT_SIZE_ESTIMATOR` inaccurately predicts size for destination `Buffer`. For aggregated API we may use `getSerializedSize()` to allocate enough bytes for destination `Buffer`. 3. `MessageLite.writeTo(OutputStream)` creates an internal copy of data that could be avoided if we create `CodedOutputStream` from internal data storage of destination `Buffer`. Modifications: - Create optimized version of `CodedInputStream` for `ProtoDeserializer` to do less copying during proto deserialization; - Provide a number of `bytesEstimate` for serialization for aggregated API; - Create optimized version of `CodedOutputStream` for `ProtoSerializer` to do less copying during proto serialization; Results: Less copying during protobuf serialization/deserialization leads to improved throughput by 5-15% on the gRPC client and server when they (de)serialize 16Kb payload body.
- Loading branch information
Showing with 55 additions and 9 deletions.