Avoid some allocations in recvMsg

Reading the header by hand avoids some allocations and improves the
performance of recvMsg.

benchmark                              old ns/op     new ns/op     delta
BenchmarkClientStreamc1-8              125267        110733        -11.60%
BenchmarkClientStreamc8-8              21561         20971         -2.74%
BenchmarkClientStreamc64-8             13573         12825         -5.51%
BenchmarkClientStreamc512-8            13937         13300         -4.57%
BenchmarkClientUnaryc1-8               223208        257968        +15.57%
BenchmarkClientUnaryc8-8               46168         45618         -1.19%
BenchmarkClientUnaryc64-8              33740         33038         -2.08%
BenchmarkClientUnaryc512-8             33137         32663         -1.43%
BenchmarkClientStreamNoTracec1-8       115559        107506        -6.97%
BenchmarkClientStreamNoTracec8-8       20853         20376         -2.29%
BenchmarkClientStreamNoTracec64-8      12119         11935         -1.52%
BenchmarkClientStreamNoTracec512-8     13087         12479         -4.65%
BenchmarkClientUnaryNoTracec1-8        225577        244701        +8.48%
BenchmarkClientUnaryNoTracec8-8        42211         41884         -0.77%
BenchmarkClientUnaryNoTracec64-8       30313         29655         -2.17%
BenchmarkClientUnaryNoTracec512-8      29914         29637         -0.93%

benchmark                              old allocs     new allocs     delta
BenchmarkClientStreamc1-8              46             40             -13.04%
BenchmarkClientStreamc8-8              47             41             -12.77%
BenchmarkClientStreamc64-8             46             40             -13.04%
BenchmarkClientStreamc512-8            46             40             -13.04%
BenchmarkClientUnaryc1-8               100            91             -9.00%
BenchmarkClientUnaryc8-8               100            91             -9.00%
BenchmarkClientUnaryc64-8              100            91             -9.00%
BenchmarkClientUnaryc512-8             96             88             -8.33%
BenchmarkClientStreamNoTracec1-8       42             36             -14.29%
BenchmarkClientStreamNoTracec8-8       43             37             -13.95%
BenchmarkClientStreamNoTracec64-8      42             36             -14.29%
BenchmarkClientStreamNoTracec512-8     42             36             -14.29%
BenchmarkClientUnaryNoTracec1-8        87             78             -10.34%
BenchmarkClientUnaryNoTracec8-8        87             78             -10.34%
BenchmarkClientUnaryNoTracec64-8       87             78             -10.34%
BenchmarkClientUnaryNoTracec512-8      84             77             -8.33%

benchmark                              old bytes     new bytes     delta
BenchmarkClientStreamc1-8              2015          1919          -4.76%
BenchmarkClientStreamc8-8              2016          1920          -4.76%
BenchmarkClientStreamc64-8             2015          1919          -4.76%
BenchmarkClientStreamc512-8            2007          1901          -5.28%
BenchmarkClientUnaryc1-8               5981          5837          -2.41%
BenchmarkClientUnaryc8-8               5980          5837          -2.39%
BenchmarkClientUnaryc64-8              5956          5813          -2.40%
BenchmarkClientUnaryc512-8             5743          5611          -2.30%
BenchmarkClientStreamNoTracec1-8       1887          1791          -5.09%
BenchmarkClientStreamNoTracec8-8       1888          1792          -5.08%
BenchmarkClientStreamNoTracec64-8      1916          1789          -6.63%
BenchmarkClientStreamNoTracec512-8     1894          1811          -4.38%
BenchmarkClientUnaryNoTracec1-8        4301          4158          -3.32%
BenchmarkClientUnaryNoTracec8-8        4301          4157          -3.35%
BenchmarkClientUnaryNoTracec64-8       4282          4140          -3.32%
BenchmarkClientUnaryNoTracec512-8      4131          4077          -1.31%
1 file changed
tree: b32aff6a3a115a4839d39bcc171e587e81e73ff7
  1. benchmark/
  2. codes/
  3. credentials/
  4. Documentation/
  5. examples/
  6. grpclog/
  7. health/
  8. interop/
  9. metadata/
  10. naming/
  11. test/
  12. transport/
  13. .travis.yml
  14. call.go
  15. clientconn.go
  16. codegen.sh
  17. CONTRIBUTING.md
  18. doc.go
  19. LICENSE
  20. Makefile
  21. PATENTS
  22. picker.go
  23. README.md
  24. rpc_util.go
  25. rpc_util_test.go
  26. server.go
  27. stream.go
  28. trace.go
README.md

#gRPC-Go

Build Status GoDoc

The Go implementation of gRPC: A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information see the gRPC Quick Start guide.

Installation

To install this package, you need to install Go 1.4 or above and setup your Go workspace on your computer. The simplest way to install the library is to run:

$ go get google.golang.org/grpc

Prerequisites

This requires Go 1.4 or above.

Constraints

The grpc package should only depend on standard Go packages and a small number of exceptions. If your contribution introduces new dependencies which are NOT in the list, you need a discussion with gRPC-Go authors and consultants.

Documentation

See API documentation for package and API descriptions and find examples in the examples directory.

Status

Beta release