use proto.Buffer API for protobuf codec and cache proto.Buffer structs (#1010)

* use a global sharded pool of proto.Buffer caches in protoCodec

* fix goimports

* make global buffer pool index counter atomic

* hack to remove alloc in encode_len_struct

* remove extra slice alloc in proto codec marshal

* replce magic number for proto size field length with constant

* replace custom cache with sync.Pool

* remove 1 line functions in codec.go and add protoCodec microbenchmarks

* add concurrent usage test for protoCodec

* fix golint.gofmt,goimport checks

* fix issues in codec.go and codec_test.go

* use go parallel benchmark helpers

* replace proto.Codec with a guess of size needed

* update Fatalf -> Errorf in tests

* wrap proto.Buffer along with cached last size into larger struct for pool use

* make wrapped proto buffer only a literal

* fix style and imports

* move b.Run into inner function

* reverse micro benchmark op order to unmarshal-marshal and fix benchmark setup-in-test bug

* add test for large message

* remove use of defer in codec.marshal

* revert recent changes to codec bencmarks

* move sub-benchmarks into >= go-1.7 only file

* add commentfor marshaler and tweak benchmark subtests for easier usage

* move build tag for go1.7 on benchmarks to inside file

* move build tag to top of file

* comment Codec, embed proto.Buffer into cached struct and add an int32 cap
4 files changed
tree: 9adb687cfb7a2e7f753556792a4c782868df145f
  1. benchmark/
  2. codes/
  3. credentials/
  4. Documentation/
  5. examples/
  6. grpclb/
  7. grpclog/
  8. health/
  9. internal/
  10. interop/
  11. keepalive/
  12. metadata/
  13. naming/
  14. peer/
  15. reflection/
  16. stats/
  17. status/
  18. stress/
  19. tap/
  20. test/
  21. testdata/
  22. transport/
  23. .travis.yml
  24. backoff.go
  25. backoff_test.go
  26. balancer.go
  27. balancer_test.go
  28. call.go
  29. call_test.go
  30. clientconn.go
  31. clientconn_test.go
  32. codec.go
  33. codec_benchmark_test.go
  34. codec_test.go
  35. codegen.sh
  36. CONTRIBUTING.md
  37. coverage.sh
  38. doc.go
  39. interceptor.go
  40. LICENSE
  41. Makefile
  42. PATENTS
  43. README.md
  44. rpc_util.go
  45. rpc_util_test.go
  46. server.go
  47. server_test.go
  48. stream.go
  49. 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 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.6 or later.

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

GA

FAQ

Compiling error, undefined: grpc.SupportPackageIsVersion

Please update proto package, gRPC package and rebuild the proto files:

  • go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
  • go get -u google.golang.org/grpc
  • protoc --go_out=plugins=grpc:. *.proto