3190 Commits

Author SHA1 Message Date
642675125e codec/proto: reuse of marshal byte buffers (#3167)
Performance benchmarks can be found below. Obviously, a 8 KiB
request/response is tailored to showcase this improvement as this is
where codec buffer reuse shines, but I've run other benchmarks too (like
1-byte requests and responses) and there's no discernable impact on
performance.

We do not allow reuse of buffers when stat handlers or binlogs are
turned on. This is because those two may need access to the data and
payload even after the data has been written to the wire. In such cases,
we never return the data back to the pool.

A buffer reuse threshold of 1 KiB was determined after several
experiments. There's diminished returns when buffer reuse is enabled for
smaller messages (actually, a negative impact).

unary-networkMode_none-bufConn_false-keepalive_false-benchTime_40s-trace_false-latency_0s-kbps_0-MTU_0-maxConcurrentCalls_6-reqSize_8192B-respSize_8192B-compressor_off-channelz_false-preloader_false
               Title       Before        After Percentage
            TotalOps       839638       906223     7.93%
             SendOps            0            0      NaN%
             RecvOps            0            0      NaN%
            Bytes/op    103788.29     80592.47   -22.35%
           Allocs/op       183.33       189.30     3.27%
             ReqT/op 1375662899.20 1484755763.20     7.93%
            RespT/op 1375662899.20 1484755763.20     7.93%
            50th-Lat    238.746µs    225.019µs    -5.75%
            90th-Lat    514.253µs    456.439µs   -11.24%
            99th-Lat    711.083µs    702.466µs    -1.21%
             Avg-Lat     285.45µs    264.456µs    -7.35%
2019-12-20 09:41:23 -08:00
ffcdcbc762 profiling: add cmd binary for retrieving and processing data (#3161) 2019-12-20 09:28:08 -08:00
fb8a097792 xds: Improve cdsbalancer_test.go (#3277)
* Use the fakexds.Client object instead of defining a new one
* Add CDS watch functionality to the fakexds.Client object
2019-12-19 13:47:34 -08:00
f42dee19bb trace: fix getting family for the method (#3216) 2019-12-19 13:23:11 -08:00
9819552c93 xds: Improve xds_resolver_test.go (#3259)
Also get rid of the testutils.XDSClient type. We have a new
testutils/fakexds/Client type which will be used in tests going forward.
2019-12-19 09:21:11 -08:00
d44b1112a2 profiling: add proto and service (#3160) 2019-12-19 08:54:38 -08:00
fcf817f67c dns: report errors from A record lookups instead of zero addresses (#3258) 2019-12-19 08:53:07 -08:00
660df6a06b xds: Improve xds_client_test.go (#3270)
Simplified the tests by only testing what is required and faking out
whatever can be faked out.

Also added a fakexds.Server implementation. Will switch other users of
the existing fakeserver implementation after this PR is merged.
2019-12-18 14:17:35 -08:00
04c179315b xds: support multiple xds servers in bootstrap file (#3247)
Changes to "xds_server" field in bootstrap file:

1. Field name is changed "xds_servers" (plural).
2. Field value should be a list of objects instead of a single object.

For now, we can ignore all entries except the first one.  In the future, we will add support for falling back to a secondary server when the primary is not reachable.
2019-12-18 13:50:05 -08:00
f324900496 dns: fix timing-based test to be more reliable (#3269)
Also, changed the test to make it run in less time and perform more iterations.
2019-12-18 12:46:31 -08:00
a281b506e1 xds test: read ACK to clear req chan (#3266)
The real test relies on req chan to know when the fake xds server
receives the request. Without this, req chan may unblock for the ack,
before the real watch handler is ready.
2019-12-18 12:35:58 -08:00
9efef0360f Change version to 1.27.0-dev (#3263) 2019-12-17 14:10:24 -08:00
d01454da4a xds: Improve balancere/xds_test.go. (#3256) 2019-12-17 11:42:43 -08:00
f7b39d80aa profiling: Fix a data race in the circular buffer. (#3254) 2019-12-13 15:56:14 -08:00
e3baa761f4 grpc: Defer the unlock in newCCResolverWrapper (#3255)
Although the existing code wasn't causing a deadlock or causing
goroutines to hang forever, this is cleaner and prevents any such thing
from happening in the future.
2019-12-13 10:55:51 -08:00
085c980048 grpclb: do not send redundant empty load reports to remote LB (#3249)
Small refactor of tests:

- Add a channel to remoteBalancer on which to send received stats messages
- Change runAndGetStats to runAndCheckStats to allow for faster successful test
  runs (no longer need to sleep for one whole second per test).
- Remove redundant leak check from runAndCheckStats, otherwise excess load
  report messages not read from the channel will result in an infinite loop.
- Add String method to rpcStats to avoid data race between merging and printing.
2019-12-12 14:10:47 -08:00
df18b5433b xds: support ack/nack (#3227)
The client will send a request with version/nonce after receiving a
response, to ack/nack.

Ack versions for different xds types are independent.

Some other changes
- merge sendRequests to one shared function, with fields for version/nonce
- deleted enum for xds types, and always use const URL string
2019-12-12 13:39:56 -08:00
032a3799b2 godoc: clarify WithTimeout deprecation note (#3226)
Tell people to replace Dial + WithTimeout with DialContext + context.WithTimeout.
2019-12-12 13:29:02 -08:00
cb0e11b54f benchmark: include go and grpc version in result files (#3242) 2019-12-12 13:18:36 -08:00
d5c817b906 xds: Improve xds_lrs_test.go (#3251) 2019-12-12 12:04:14 -08:00
4323b783fd Update README.md (#3231) 2019-12-11 13:12:25 -08:00
9f02faeffa credentials: move TLS implementation to a separate file (#3243) 2019-12-11 13:11:24 -08:00
021bd5734e profiling: add internal changes to support profiling of gRPC (#3158) 2019-12-11 09:06:38 -08:00
505c0d6440 xds: skip callback if xds client reports error (#3240)
Errors will be handled specifically, depending on whether it's a
connection error or other types of errors.

Without this fix, balancer's callback will be called with <nil> update,
causing nil panic later.
2019-12-10 14:03:21 -08:00
81a07a98fe internal: Improve documentation around buffer.Unbounded (#3241) 2019-12-10 13:45:32 -08:00
3a4f66e0ed xds: small fixes (#3238)
- install cds balancer by importing package cdsbalancer
 - `net.SplitHostPort` fails when target doesn't have port, but we want to use the original string instead
2019-12-10 12:49:47 -08:00
11399004a9 xds: resolver test cleanup (#3233)
This PR also adds a new testutils directory with a fake client and a
channel which supports a timed receive operation. In follow up PRs, we
can move other common test stuff like the fake server etc to this
directory and cleanup more tests.
2019-12-10 11:20:06 -08:00
a4e9d9553d xds: Update the check for match field when handling an RDS response. (#3239)
The client will look only at the last route in the list (the default
route), whose match field must contain a prefix field whose value is the
empty string and whose route field must be set.
2019-12-10 10:47:05 -08:00
86c8a0cb87 xds/resolver: Add missing double quote in json SC (#3232) 2019-12-06 15:39:45 -08:00
3180dcb49d server.go: combine defers to reduce stack usage (#3208)
Continuing the war on stacks, we can reduce the amount of stack required
per-RPC by combining defers from different components into one.

Each defer statement in process{Unary,Streaming}RPC goes on the stack
and occupies about 56-64 bytes the entire lifetime of an RPC, which
could be very long. More importantly, a call to runtime.morestack is
often required to allocate a new, larger stack when the handler
goroutine runs out of stack memory (Go's default stack size is 2 KiB).

Before:

    $ go tool objdump <binary> | grep "TEXT.*processUnaryRPC(SB)" -A 10 | grep "SUBQ.*SP"
      server.go:867   0x9132fb    4881ec80030000      SUBQ $0x380, SP
    $ go tool objdump <binary> | grep "TEXT.*processStreamingRPC(SB)" -A 10 | grep "SUBQ.*SP"
      server.go:1099  0x9151bb    4881ec68020000      SUBQ $0x268, SP

After:

    $ go tool objdump <binary> | grep "TEXT.*processUnaryRPC(SB)" -A 10 | grep "SUBQ.*SP"
      server.go:867   0x9132fb    4881ecd0020000      SUBQ $0x2d0, SP
    $ go tool objdump <binary> | grep "TEXT.*processStreamingRPC(SB)" -A 10 | grep "SUBQ.*SP"
      server.go:1116  0x9150fb    4881ecf8010000      SUBQ $0x1f8, SP

As one can observe, the processUnaryRPC's stack goes down from 0x380
bytes to 0x2d0 bytes (896 - 720 = 176 bytes) while processStreamingRPC's
stack goes down from 0x2d8 bytes to 0x1f8 bytes (616 - 504 = 112 bytes).

There are probably other things we can do here, but these are some low
hanging fruits to pick off.
2019-12-05 14:50:20 -08:00
da3b1eb45e xds: Implementation of the CDS LB policy. (#3224) 2019-12-05 09:52:43 -08:00
6f8ce09297 dns: reapply "dns: stop polling for updates; use UpdateState API" (#3228) 2019-12-05 08:08:29 -08:00
895b36ddf2 travis: run interop tests with examples (#3229) 2019-12-04 15:55:45 -08:00
14426e9c3a credentials/alts: Ensure that GetBytesConsumed is in-bound (#3225) 2019-12-03 22:21:17 -08:00
22854c88e0 credentials/alts: Simplify ALTS acquire and release APIs (#3221) 2019-12-03 15:43:33 -08:00
645dd12f13 alts: Update handshaker.pb.go 2019-12-03 15:28:59 -08:00
1e36139a79 credentials/alts: Set the handshake extra slice correctly (#3222) 2019-12-03 11:01:32 -08:00
4b2104f1fb xds: change lrs server name field in xds balancer config to a string pointer (#3210)
LRS is disabled if this field is nil (is unset in json). The xds server
will be used if it's a pointer to an empty string.
2019-11-27 15:11:47 -08:00
9dc72d1df0 Revert "dns: stop polling for updates; use UpdateState API" (#3213)
This reverts commit e5e980f2766388fc243cc4cf20c59b9c13affa8c.
2019-11-26 16:07:43 -08:00
157dc9f3e4 xds: cleanup eds tests to use fakexds server (#3209)
And move LRS test server to fakexds package.
2019-11-26 15:53:20 -08:00
7e7050be6a xds: Minor refactoring, prep for CDS LB policy (#3211) 2019-11-26 11:11:54 -08:00
d8e3da36ac xds: in EDS balancer, use xds_client from attibutes (#3205) 2019-11-25 14:50:28 -08:00
1c4070c2e9 xds: CDS implementation in v2Client. (#3203) 2019-11-25 09:14:33 -08:00
e5e980f276 dns: stop polling for updates; use UpdateState API (#3165) 2019-11-22 15:48:45 -08:00
cb47f381a7 dns: do not call NewServiceConfig when lookups are disabled (#3201) 2019-11-22 13:38:04 -08:00
da649b3624 xds: use the shared xds client in eds balancer (#3197)
This PR removes the xds_client implementation from eds balancer, and replaces it with a xds_client wrapper. (The xds_client wrapper has very similar API as the old xds_client implementation, so the change in the eds balancer is minimal).

The eds balancer currently doesn't look for xds_client from attributes, and always creates a new xds_client. The attributes change will be done in a following up change.
2019-11-21 14:10:04 -08:00
0e8c6a3281 github: make stalebot monitor PRs, too (#3202) 2019-11-21 12:37:51 -08:00
dc49de8acd balancer: add V2Picker, ClientConn.UpdateState, SubConnState.ConnectionError (#3186)
Also implement V2 versions of base.*, xds, pickfirst, grpclb, and round robin balancers.
2019-11-21 10:27:29 -08:00
7c1d326729 benchmark: Enable server keepalive in benchmarks (#3196) 2019-11-20 09:06:10 -08:00
24b653e8cc xds: Don't override dialFunc in xdsClient in tests. (#3191)
* Add a helper to the fakexds package to return a ClientConn talking to
  the fake server.
* Tests will make use of this ClientConn wherever required, or they will
  directly pass the fake server's address as the balancerName to the
  xdsclient.New() function, thus exercising that code path as well.
* Add grpc.WithTimeout to list in vet.sh
2019-11-20 09:02:53 -08:00