Commit Graph

700 Commits

Author SHA1 Message Date
ZHANG Dapeng 2d454d478c
Revert "Revert "all: remove deprecated usePlaintext(boolean)""
This reverts commit 316a739e67.
2019-11-18 16:53:52 -08:00
Kun Zhang d77419557a
netty: reduce default worker ELG thread number by half, to number of CPU cores (#6439)
This would cut the amount of per-thread direct buffer allocations by half, especially with light traffic. This will also cut the amount of file descriptors that's created per thread by half.

Internal benchmark results (median of 5 runs) doesn't show any significant change:
```
                          Before (STDEV)           After (STDEV)
grpc-java-java-multi-qps-integrity_only
Actual QPS               711,004 (6,246)         704,372 (6,873) 
QPS per Client CPU        23,921   (252)          24,188   (252)

grpc-java-java-multi-throughput-integrity_only
Actual QPS                35,326    (48)          35,294    (29) 
QPS per Client CPU         3,362    (17)           3,440    (13)

grpc-java-java-single-latency-integrity_only
Median latency (us)          127  (2.77)             129  (3.13)

grpc-java-java-single-throughput-integrity_only
Actual QPS                   581 (11.60)             590  (7.08)
QPS per Client CPU           490 (10.98)             498  (5.63)
```
2019-11-18 16:26:37 -08:00
Kun Zhang 89cd64328d
netty: provide an option to lower netty allocator chunk size from 16MB to 2MB (#6407)
This would reduce the amount of direct buffer allocations, especially with light traffic. This should mitigate internal issue b/143075435

The change is currently optional and is only effective if system property "io.grpc.netty.useCustomAllocator" is set to "true" ignoring the case.

Internal benchmark results (median of 5 runs) doesn't show any significant change:
```
                          Before (STDEV)           After (STDEV)
grpc-java-java-multi-qps-integrity_only
Actual QPS               717,848 (7,445)         715,061 (2,122) 
QPS per Client CPU        23,768   (799)          23,842   (295)

grpc-java-java-multi-throughput-integrity_only
Actual QPS                35,631   (204)          35,298    (25) 
QPS per Client CPU         3,362    (56)           3,316    (18)

grpc-java-java-single-latency-integrity_only
Median latency (us)          130  (1.82)             125  (5.36)

grpc-java-java-single-throughput-integrity_only
Actual QPS                    593 (5.14)             587  (3.76)
QPS per Client CPU            502 (4.51)             494  (6.92)

```
2019-11-14 15:50:11 -08:00
Steve Rao 1118793bfb netty: improve code readability (#6375) 2019-11-12 08:48:58 -08:00
Steve Rao a408d086bd netty: unified log prompt (#6386) 2019-11-05 19:47:50 -08:00
Steve Rao 1adf403bb1 netty: remove redundant variable references 2019-11-05 17:48:51 -08:00
Eric Anderson 28149944ad netty: Deflake WriteBufferingAndExceptionHandlerTest
It appears the problem is that server.close() was missing sync(), so the
event loop was still processing the closure when the next test started.

This change is more aggressive than it needs to be, but should make it
less bug-prone.

Fixes #5574
2019-11-04 17:52:57 -08:00
sanjaypujare 48b41dce9e
xds: Client and server proto negotiators and handlers added to SdsProtocolNegotiators (#6319) 2019-10-24 15:27:53 -07:00
Jihun Cho c166ec2c4e netty: use FINE log for pure IOExceptions 2019-10-24 15:17:16 -07:00
ZHANG Dapeng 316a739e67
Revert "all: remove deprecated usePlaintext(boolean)"
This reverts commit 296857b4e7.
2019-10-10 15:56:47 -07:00
ZHANG Dapeng 296857b4e7
all: remove deprecated usePlaintext(boolean) 2019-10-08 09:27:39 -07:00
Eric Anderson 2caa77d48f netty: Implicitly enable Conscrypt when it is available
This implicit loading is more conservative than the loading for
tcnative, as Conscrypt will only be implicitly loaded if there are no
other options. This means the Java 9+ JSSE is preferred over Conscrypt
without explicit user configuration.

While we would generally prefer Conscrypt over JSSE, we want to allow
the user to configure their security providers. There wasn't a good way
to do that with netty-tcnative and the performance of JSSE at the time
was abysmal.

While generally being a good way to allow adopting Conscrypt, this also
allows easily using App Engine Java 8's provided Conscrypt which can
substantially reduce binary size.

See googleapis/google-cloud-java#6425
2019-10-07 11:37:50 -07:00
Jihun Cho e9ac1b4a76
all: update modules to wait until other module's sourceSet is available (#6232) 2019-10-02 15:05:44 -07:00
Carl Mastrangelo ab2aff48dc netty,okhttp,cronet: add option to use get/put when methods are safe/idempotent
This change adds two booleans to the ChannelBuilders to
allow transports to use get and put.   These are currently defaulted to
on, but unset on the method descriptors.   This change is 1/2 that will
allow the safe / idempotent bits to be set on generated proto code.
Part 2/2 will actually enable it.

The use case for this is for interceptors that implement caching logic.
They need to be able to access the safe/idempotent bits on the MD in
order to decide to how to handle the request, even if gRPC doesn't use
GET / PUT HTTP methods.
2019-09-25 14:57:17 -07:00
Eric Anderson bd48891dab netty: Check for TE header after checking Content-Type
Checking too early leads to false-positives, like if a non-gRPC client
contacts the server or a grpc-web client.
2019-09-25 14:04:19 -07:00
Jihun Cho 16392bc733
netty: converts Proxy handler into new protocol negotiation style (#6159) 2019-09-19 15:29:03 -07:00
Anar Sultanov ba0fd84d79 netty: Rely on ChannelFactory in NettyServer instead of dynamic classes
Fixes #5649
2019-09-17 15:59:29 -07:00
Eric Anderson 2b945774b6 Apply animalsniffer plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 4215b80b81 Apply java plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson e13221b503 Apply japicmp plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 3b29f74271 Move ALPN Agent configuration to each project needing it 2019-09-13 09:42:17 -07:00
Eric Anderson 5b838e5284 Apply maven-publish plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 55ac6f08af Apply JMH plugin explicitly when needed 2019-09-13 09:42:17 -07:00
Eric Anderson 3c3a823a81 Swap to Gradle's Plugin DSL for much of build
Examples and android projects were left unchanged. They can be changed
later.

No plugin versions were changed, to make this as non-functional of a
change as possible. Upgrading Gradle to 5.6 was necessary for
pluginManagement in settings.gradle.
2019-09-13 09:42:17 -07:00
康智冬 415212fc49 alts: fix typo (#6113) 2019-09-10 14:13:35 -07:00
Eric Anderson 9d6f5322c2 bazel: Add helper for maven_install's override_targets
This can be used to prevent duplicate classes in the classpath, one via
Maven and one via Bazel-native.

See census-instrumentation/opencensus-java#1963 and #5359
2019-08-22 07:40:32 -07:00
Eric Anderson 63661c7b70 netty: Add Bazel target similar to netty-shaded
See census-instrumentation/opencensus-java#1963
2019-08-21 09:48:20 -07:00
Carl Mastrangelo 21c34d7862
netty: check for null protocol negotiator in NettyChannelBuilder 2019-08-15 11:11:31 -07:00
Carl Mastrangelo 458f4533db
netty: migrate Server protocol negotiation to new style
* Revert "Revert "netty: change server to new protocol negotiator model" (#5798)"

This reverts commit 4e5e19f6fd.
2019-08-14 13:00:42 -07:00
Eric Anderson 9fcfb5b4f8
netty: Limit number of frames client can cause server to enqueue
Http2ControlFrameLimitEncoder is from Netty. It is copied here as a
temporary measure until we upgrade to the version of Netty that includes
the class.

See CVE-2019-9515
2019-08-13 12:24:15 -05:00
Laurent Le Brun 503696aa9a bazel: Remove missing pattern from glob
There's no third_party directory.
This change makes the repository compatible with
Bazel change --incompatible_disallow_empty_glob.
2019-08-08 16:41:17 -07:00
Jihun Cho 4faad27078
netty: record ByteBuf access in Netty{Client,Server}Stream before calling MessageDeframer (#6027) 2019-08-02 16:25:08 -07:00
Jihun Cho 65109e6738
netty: Netty{Server,Channel}Builder requires all or none of ELG and ChannelType (#6014) 2019-07-26 09:25:02 -07:00
Carl Mastrangelo cc524f10d3
netty,interop-testing: increase timeouts on tests for TSAN 2019-07-19 15:24:19 -07:00
Carl Mastrangelo 25a72e1f6d
netty: don't share transport tracers across transports
Found using TSAN, which shows the number of calls succeeded being incremented from multiple event loops
2019-07-15 11:18:35 -07:00
Carl Mastrangelo 855740622a
all: bump PerfMark to 0.17.0
* Bump PerfMark to 0.17.0

The main changes how linking is done.  Linking is now always done
through the `PerfMark` entry class.   This is for two reasons:

1.  It make instrumenting the linking calls *much* easier.
2.  It follows the API pattern of "verbNoun()".  Previous callsites
    would have `Link link = PerfMark.link(); link.link()`.  This
    stuttering is not quick to follow.

Generated using:

```
find -name \*.java -exec sed -i 's#link = PerfMark.link();#link = PerfMark.linkOut();#g' {} \;
find -name \*.java -exec sed -i 's#link.link();#PerfMark.linkIn(link);#g' {} \;
find -name \*.java -exec sed -i 's#command.getLink().link();#PerfMark.linkIn(command.getLink());#g' {} \;
find -name \*.java -exec sed -i 's#cmd.getLink().link();#PerfMark.linkIn(cmd.getLink());#g' {} \;
find -name \*.java -exec sed -i 's#msg.getLink().link();#PerfMark.linkIn(msg.getLink());#g' {} \;
```

Since the deprecated link methods are also `@DoNotCall`, the same
sed calls will need to be used on import.
2019-07-11 10:57:05 -07:00
Carl Mastrangelo 9aa3981ada
netty: use varargs logger in ProtocolNegotiators 2019-06-27 15:59:43 -07:00
Carl Mastrangelo 023b9a3f14
netty: don't use InternalProtocolNegotiators in ProtocolNegotiators 2019-06-27 15:07:43 -07:00
Carl Mastrangelo 0a1805db43
netty: include pipeline on exceptions too 2019-06-27 13:04:31 -07:00
Carl Mastrangelo 9e5f60b86a
netty: upstream ProtocolNegotiatiorHandler, and swap the appropriate classes to it
ALTS is not switched yet, since it is shared between client and server. Once the server is changed to use WBAEH, it can be moved too.
2019-06-26 18:23:12 -07:00
Carl Mastrangelo 7895c33efa
netty: make unexpected reads fail negotiation, and log close failures
In case a negotiating handler misses a read, and it reaches the WBAEH, it should cause a failure. Also, if closing the channel fails while handling another error, log the second failure.
2019-06-26 14:43:06 -07:00
ZHANG Dapeng 18645422c9
netty: Delete deprecated HandlerSettings 2019-06-20 11:34:19 -07:00
Eric Anderson 29cb7c4dd4 netty: Use await instead of sync
We only care about when closing is done, not whether it is successful or not.
If there's a failure, we're already going to log a warning. Use await to avoid
throwing unexpectedly.
2019-06-20 07:19:56 -07:00
Carl Mastrangelo 74e945ceb4
core,netty: block server shutdown until the socket is unbound 2019-06-19 17:23:08 -07:00
Eric Anderson 3d289213ce
netty-shaded: Use compile instead of runtime dependency in pom (#5901)
Maven does not include transitive runtime dependencies in the
compile-time classpath (testing shows Gradle 4 does; docs say
Gradle 5 doesn't). So if a user references the shaded
NettyServerBuilder without also depending on grpc-core directly,
compilation will fail because AbstractServerImplBuilder couldn't
be found.

This isn't technically a problem, since we're not wanting to encourage
users to reference the shaded classes directly. But some users will
certainly reference the classes anyway and the error is pretty confusing
while also being trivially worked around. In other words: it justs
wastes people's time and benefits nobody.

Fixes #5881
2019-06-19 09:51:00 -07:00
Carl Mastrangelo 9c9ca659d4
netty,alts: fire initial protocol negotiation event in WBAEH
This change is needed after trying to use the new style protocol negotiators internally.  The problem is that some handlers fire the event in handlerAdded, which is too early.  The followup PNE is fired after handlerAdded, which breaks the composibility of the negotiators.

To fix this, this change modifies the negotiation flow.  Specifically:

* Negotiators should NEVER fire a negotiation from handlerAdded, instead they should wait until userEventTriggered
* Negotiators now do state checking on the PNE.  If it is set twice, it fails.  If it has not been received when doing the next stage of negotiation, it fails.
* WBAEH now fires the initial, default event.  This is the only handler that can fire it from handlerAdded

The tests updated are ones not using WBAEH (which they probably should).  This change ensures attributes aren't lost when doing negotiation.
2019-06-18 09:33:40 -07:00
Carl Mastrangelo 40854dc9e1
core,netty: use PerfMark tags with the HTTP/2 stream ids
This change removes the WriteQueue linking and splits it out into each
of the commands, so that the trace is more precise, and the tag
information is correct.

It is still unclear what the initial Tag should be for ClientCallImpl,
since it should not access the TransportState to get the HTTP/2 stream id.
2019-06-17 15:25:39 -07:00
Carl Mastrangelo e5bd7f282c
Revert "Revert "core, netty: add io.perfmark Annotations" (#5853)" (#5884)
This reverts commit 2db3abc9ad.
2019-06-14 14:09:05 -07:00
Nick Travers 6aed34231f netty: refine filtering for benign transport level exceptions
Transport level exceptions (e.g. "Connection reset by peer") are not
useful and clutter the logs. `NettyServerTransport` contains logic to
log such exceptions at level `FINE`.

When running with epoll, transport level exceptions are prefixed with
additional contextual information (e.g. "syscall:read(..) failed:") that
causes the exceptions to be logged at level `INFO`.

Update the filtering logic to match on error messages _containing_ the
blacklisted messages, rather than using string equality.

Closes #5872.

Signed-off-by: Nick Travers <n.e.travers@gmail.com>
2019-06-13 09:24:36 -07:00
Carl Mastrangelo 2db3abc9ad
Revert "core, netty: add io.perfmark Annotations" (#5853)
This causes internal breakage which needs to be resolved before continuing.

This reverts commit 71967622d6.
2019-06-07 17:23:49 -07:00