82 Commits

Author SHA1 Message Date
ce595b8452 Implement EmptyCallOption 2017-05-17 14:47:38 -07:00
88a73d35c9 Adding dial options for PerRPCCredentials (#1225)
* Adding dial options for PerRPCCredentials

* Added tests for PerRPCCredentials

* Post-review updates

* post-review updates
2017-05-11 11:07:38 -07:00
600406e696 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] db12f9d4e4

Signed-off-by: Steeve Morin <steeve.morin@gmail.com>
2017-05-10 16:40:25 -07:00
a40b8d44e0 Address the comments 2017-05-04 16:29:17 -07:00
0eb507a2ca Change version to 1.4.0-dev (#1212) 2017-04-28 15:32:14 -07:00
277e90a432 Client load report for grpclb. (#1200) 2017-04-27 10:43:38 -07:00
955c867061 Support proxy with dialer (#1098)
With this change, the default dialer checks environment variables to see if proxy is needed. If so, it dials to the proxy and does an HTTP CONNECT handshake.
2017-04-17 16:08:50 -07:00
0e8b58d22f 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
2017-04-12 20:35:59 -07:00
1d27587e10 Change status package to deal with concrete types instead of interfaces (#1171) 2017-04-06 11:41:07 -07:00
b507112439 Add status package for reporting gRPC status and errors (#1156)
When an error implemented by the status package is returned from a service
handler, the server will transmit a rich status message in the
"grpc-status-details-bin" trailing metadata field if any detailed data is
attached to the error.  Client-side, we will decode them if present in the
server's response and return them to the user code performing the RPC.

This is backward compatible with the existing errors supported by the grpc
package.  However, the grpc.Errorf, grpc.Code and grpc.ErrorDesc functions for
managing errors are now deprecated; status.Errorf and status.Status type
asserions should be used instead.
2017-04-05 10:35:40 -07:00
f45e6e3b30 Bug fix(Issue#1141): Check if peer is nil before trying to derefer it. (#1143) 2017-04-04 15:08:14 -07:00
14a6be430b Add grpc.Version string and use it in the UA (#1144) 2017-03-24 11:29:02 -07:00
9871e09f09 Use codes.Code.String() rather than logging integers
This produces better human-readable error messages.
2017-02-27 14:13:02 -05:00
6810d34606 fix issue #1056 and #1050 2017-02-13 17:37:53 -08:00
dfb494c6e5 post review update 2017-02-08 14:15:59 -08:00
66de296a37 post review update 2017-02-07 14:46:28 -08:00
794873f0a2 Added calloption to retrieve peer information 2017-02-07 10:41:32 -08:00
6e0ace39fe Change max message size fields from uint64 to uint32. 2017-01-26 14:43:08 -08:00
325a0c2061 Update comment. 2017-01-09 12:59:10 -08:00
09aecb094e Add the initial service config support (#1009)
* Add the initial service config support

* start scWatcher later

* remove timeoutCh

* address the comments

* deal with dial timeout

* defer cancel for the newly created context for correct lifetime management

* fix the defer order

* added other 2 missing cancels
2016-12-19 16:31:00 -08:00
3f9a96ea71 move inPayload.RecvTime to after unmarshal 2016-11-07 16:29:25 -08:00
5938492b60 fix comments 2016-11-07 15:16:52 -08:00
a4edc462a2 renaming 2016-11-07 15:16:52 -08:00
c698588285 Renaming types and variables 2016-11-07 15:16:52 -08:00
1054f1c42b add payload with original type to payload stats 2016-11-07 15:16:52 -08:00
17ee5a3637 Add package stats, and export stats on server side. 2016-11-07 15:16:52 -08:00
727a60e4d1 update server reflection code to comply with the change to the grpc generator 2016-10-21 18:06:55 -07:00
5e734ab23e Avoid creating transport stream error outside of transport 2016-09-02 11:57:42 -07:00
fc500c24f6 fix go vet error 2016-07-29 18:08:00 -07:00
b13920a0cf add the mem alloc guard on server 2016-07-29 16:19:20 -07:00
8c908a8c1d Reject over-sized requests on server 2016-07-26 16:44:49 -07:00
ffdfb592e8 Fix type assertion error after rebase 2016-07-08 10:35:38 -07:00
3802318f46 Make Errorf return pointer to rpcError 2016-07-08 10:28:36 -07:00
be59d023f2 refactor error handling a bit 2016-06-29 15:21:44 -07:00
213a20c4fe bug fix, typo fix and slight error refactoring 2016-06-28 16:08:19 -07:00
01ef81a4d9 minor fix including removal of debugging logs, error code fix, etc. 2016-06-27 15:30:20 -07:00
3e71fb360d Support fail-fast mode and make it the default 2016-06-27 14:36:59 -07:00
cf04b299b7 Change SupportPackageIsVersion variable 2016-06-10 11:48:20 -07:00
487ada6517 Fixed typos in docstrings 2016-06-07 12:01:07 +01:00
e0f9f26e85 remove the checking of empty string for recvCompress 2016-05-11 11:01:26 -07:00
b506f13d5b change the error code when the required decompressor is not installed 2016-05-11 10:46:23 -07:00
113bf2f219 Change some compression related error code 2016-05-10 13:54:10 -07:00
61e92eacc3 Phase 1 to add the server interceptor 2016-04-18 16:18:34 -07:00
d07d0562ff Merge pull request #601 from stevvooe/backoff-strategy
backoff: allow configuration of backoff strategy
2016-04-11 10:32:33 -07:00
47b74a63a8 backoff: allow configuration of backoff strategy
The backoff function and parameters have been pulled up into an
interface `backoffStrategy`. The default parameters are now part of a
package variable `DefaultBackoffConfig`. The strategy is then plumbed
through `dialOptions`. As a result of this PR, the
maximum backoff delay can now be set using the `WithBackoffConfig` dial
option.

While the addition of strategy may seem premature, this allows one to
simply export `BackoffStrategy` and `WithBackoff` to allow arbirarily
configurable backoff strategies.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
2016-04-07 20:17:57 -07:00
71e3dbec56 Use ErrorDetail() to provide better error msg for malformed HTTP2 2016-03-28 11:34:29 -07:00
710dbc764f Prepare for adding a compatibility marker to proto generated code.
This will assert at build time that the generated code is compatible
with the grpc package that it is linked to. A future change in the
grpc plugin for protoc-gen-go will generate a line like
	const _ = grpc.SupportPackageIsVersion1

This constant will be renamed in the future when incompatible changes
are made that require synchronised updates to grpc and protoc-gen-go.
2016-03-07 10:12:28 +11:00
110fd99e30 Fix crashes where transports returned errors unhandled by the message parser.
The http.Handler-based transport body reader was returning error types
not understood by the recvMsg parser. See #557 for some background and
examples.

Fix the http.Handler transport and add tests. I copied in a subset of
the http2 package's serverTest type, adapted slightly to work with
grpc. In the process of adding tests, I discovered that
ErrUnexpectedEOF was also not handled by the regular server
transport. Document the rules and fix that crash as well.

Unrelated stuff in this CL:

* make tests listen on localhost:0 instead of :0, to avoid Mac firewall
  pop-up dialogs.

* rename parser.s field to parser.r, to be more idiomatic that it's an
  io.Reader and not anything fancier. (it's not acting like type
  stream, even if that's the typical concrete type)

* move 5 byte temp buffer into parser, rather than allocating it for
  each new message. (drop in the bucket improvement in garbage; more
  to do later)

* rename http2RSTErrConvTab to http2ErrConvTab, per Qi's earlier
  CL. Also add the HTTP/1.1-required error mapping for completeness,
  not that it should ever arise with gRPC, also per Qi's earlier CL
  referenced in #557.
2016-02-24 15:09:17 -08:00
7346c871b0 Add a ServeHTTP method to *grpc.Server
This adds new http.Handler-based ServerTransport in the process,
reusing the HTTP/2 server code in x/net/http2 or Go 1.6+.

All end2end tests pass with this new ServerTransport.

Fixes grpc/grpc-go#75

Also:
Updates grpc/grpc-go#495 (lets user fix it with middleware in front)
Updates grpc/grpc-go#468 (x/net/http2 validates)
Updates grpc/grpc-go#147 (possible with x/net/http2)
Updates grpc/grpc-go#104 (x/net/http2 does this)
2016-02-12 00:16:28 +00:00
af8888dc8d remove Compressor/DecompressorGenerator 2016-01-29 14:38:20 -08:00