Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal/transport: optimize grpc-message encoding/decoding #5654

Merged
merged 1 commit into from Oct 4, 2022
Merged

internal/transport: optimize grpc-message encoding/decoding #5654

merged 1 commit into from Oct 4, 2022

Commits on Sep 14, 2022

  1. internal/transport: optimize grpc-message encoding/decoding

    Use strings.Builder (introduced in Go 1.10) instead of bytes.Buffer.
    Also call fmt.Fprintf directly on the builder. This improves performance
    both in terms of CPU and memory consumption:
    
    name                 old time/op    new time/op    delta
    DecodeGrpcMessage-8     345ns ± 5%     225ns ± 4%  -34.56%  (p=0.000 n=20+20)
    EncodeGrpcMessage-8    1.33µs ± 4%    1.26µs ± 3%   -5.76%  (p=0.000 n=20+20)
    
    name                 old alloc/op   new alloc/op   delta
    DecodeGrpcMessage-8     80.0B ± 0%     24.0B ± 0%  -70.00%  (p=0.000 n=20+20)
    EncodeGrpcMessage-8      115B ± 0%       88B ± 0%  -23.48%  (p=0.000 n=20+20)
    
    name                 old allocs/op  new allocs/op  delta
    DecodeGrpcMessage-8      2.00 ± 0%      2.00 ± 0%     ~     (all equal)
    EncodeGrpcMessage-8      8.00 ± 0%      4.00 ± 0%  -50.00%  (p=0.000 n=20+20)
    tklauser committed Sep 14, 2022
    Copy the full SHA
    a9d4ee4 View commit details
    Browse the repository at this point in the history