commit | 600406e696bb27288ec8a4b501184f948f8bb222 | [log] [tgz] |
---|---|---|
author | Steeve Morin <steeve.morin@gmail.com> | Thu May 11 01:40:25 2017 +0200 |
committer | dfawley <dfawley@google.com> | Wed May 10 16:40:25 2017 -0700 |
tree | d01482e9433bd065a36afc7f97756c8249184c0e | |
parent | 4013f8d559720d4d0087cca0a3f18e0fdf25093d [diff] |
Use pooled gzip.{Writer,Reader} in gzip{Compressor,Decompressor} (#1217) This change saves a lot of memory by reusing the underlying gzip.{Writer,Reader}, which allocates up to 1.4mb at every instanciation according to [1]. This was fixed by adding a Reset method by to the object at [2]. The amount of memory (and GC time) saved is pretty high, as reported by pprof: flat flat% sum% cum cum% 28.33GB 85.70% 85.70% 32.74GB 99.05% compress/flate.NewWriter flat flat% sum% cum cum% 19.39MB 16.74% 16.74% 22.07MB 19.05% compress/flate.NewWriter And the benchmarks: benchmark old ns/op new ns/op delta BenchmarkGZIPCompressor1B-4 215170 22291 -89.64% BenchmarkGZIPCompressor1KiB-4 225971 27213 -87.96% BenchmarkGZIPCompressor8KiB-4 246696 54785 -77.79% BenchmarkGZIPCompressor64KiB-4 444851 286924 -35.50% BenchmarkGZIPCompressor512KiB-4 2279043 2115863 -7.16% BenchmarkGZIPCompressor1MiB-4 4412989 4258635 -3.50% benchmark old allocs new allocs delta BenchmarkGZIPCompressor1B-4 17 0 -100.00% BenchmarkGZIPCompressor1KiB-4 17 0 -100.00% BenchmarkGZIPCompressor8KiB-4 17 0 -100.00% BenchmarkGZIPCompressor64KiB-4 17 0 -100.00% BenchmarkGZIPCompressor512KiB-4 17 0 -100.00% BenchmarkGZIPCompressor1MiB-4 17 0 -100.00% benchmark old bytes new bytes delta BenchmarkGZIPCompressor1B-4 813872 8 -100.00% BenchmarkGZIPCompressor1KiB-4 813872 16 -100.00% BenchmarkGZIPCompressor8KiB-4 813875 27 -100.00% BenchmarkGZIPCompressor64KiB-4 813918 190 -99.98% BenchmarkGZIPCompressor512KiB-4 814928 1871 -99.77% BenchmarkGZIPCompressor1MiB-4 820889 9735 -98.81% [1] https://github.com/golang/go/issues/6138 [2] https://github.com/golang/go/commit/db12f9d4e406dcab81b476e955c8e119112522fa Signed-off-by: Steeve Morin <steeve.morin@gmail.com>
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.
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
This requires Go 1.6 or later.
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.
See API documentation for package and API descriptions and find examples in the examples directory.
GA
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