Commit Graph

1605 Commits

Author SHA1 Message Date
Jakob Buchgraber 7aa0e1a901 netty: server support extension content types (#2306)
Removed a (left over?) content type check that checks for equality with "application/grpc".
The content type is verified using checkContentType(..).
2016-09-30 10:05:21 +02:00
Eric Anderson 28ba5995de Update README to reference 1.0.1 2016-09-29 20:21:29 -07:00
Eric Anderson 60715a5674 docs: Suggest using Fork19 of tcnative
Fork17 fails with:
java.lang.NoClassDefFoundError:
org/apache/tomcat/jni/CertificateRequestedCallback

I've also seen issues of it failing silently, other than connection
hanging (which I've not dug into). Since we're using Fork19 ourselves,
we should have our users do the same.
2016-09-29 17:31:52 -07:00
Eric Anderson b1d72e5c3e all: Bump protobuf to 3.0.2, to fix protoc in CI
protoc no longer builds in 3.0.0 because auto-download of the gmock zip
now fails. 3.0.2 has a fix to autogen:
bba446bbf2

All that was strictly necessary was to update .travis.yml and
buildscripts/, but it helps our sanity to keep the rest of the protobuf
versions in sync. Lite is left on its existing version, because it did
not see a bump of neither the java library nor the protoc plugin.
2016-09-29 10:25:31 -07:00
Carl Mastrangelo 34812835a8 interop-testing: limit the amount of noise from failing tests
Also mark Netty class as internal
2016-09-28 17:09:39 -07:00
Carl Mastrangelo 3fb3af4e8a android-interop-testing: skip integration tests if there is not enough memory 2016-09-28 17:05:42 -07:00
Carl Mastrangelo f5f9ca52c8 all: fix minor bugs discovered on import 2016-09-28 14:35:51 -07:00
Łukasz Strzałkowski ce78224e0b netty: Refactor passing down SSL Session (#2295)
Create generic interface for handling passing down arbitrary attributes from
protocol negotiation handlers.

Addresses #1556.
2016-09-23 19:04:53 -07:00
Carl Mastrangelo 017f5f8808 protobuf: make buffer cache even weaker 2016-09-21 10:58:59 -07:00
Carl Mastrangelo ef4e0f4522 protobuf: cache temp buffers
Before:
TransportBenchmark.unaryCall1024                                       true        NETTY  sample  4564   2188854.745 ±  71456.423   ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00                   true        NETTY  sample         1875968.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50                   true        NETTY  sample         2105344.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90                   true        NETTY  sample         2396160.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95                   true        NETTY  sample         2535424.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99                   true        NETTY  sample         3011993.600                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999                  true        NETTY  sample         7471595.520                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999                 true        NETTY  sample        99090432.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00                   true        NETTY  sample        99090432.000                ns/op
TransportBenchmark.unaryCall1024:·gc.alloc.rate                        true        NETTY  sample    10      2787.784 ±    169.945  MB/sec
TransportBenchmark.unaryCall1024:·gc.alloc.rate.norm                   true        NETTY  sample    10   6415272.837 ±    262.046    B/op
TransportBenchmark.unaryCall1024:·gc.churn.PS_Eden_Space               true        NETTY  sample    10      2815.863 ±    429.465  MB/sec
TransportBenchmark.unaryCall1024:·gc.churn.PS_Eden_Space.norm          true        NETTY  sample    10   6483440.294 ± 947355.959    B/op
TransportBenchmark.unaryCall1024:·gc.churn.PS_Survivor_Space           true        NETTY  sample    10         2.143 ±      1.623  MB/sec
TransportBenchmark.unaryCall1024:·gc.churn.PS_Survivor_Space.norm      true        NETTY  sample    10      4873.798 ±   3679.598    B/op
TransportBenchmark.unaryCall1024:·gc.count                             true        NETTY  sample    10        42.000               counts
TransportBenchmark.unaryCall1024:·gc.time                              true        NETTY  sample    10       155.000                   ms

After:
Benchmark                                                          (direct)  (transport)    Mode   Cnt         Score        Error   Units
TransportBenchmark.unaryCall1024                                       true        NETTY  sample  5037   1982881.569 ±  16738.841   ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.00                   true        NETTY  sample         1683456.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.50                   true        NETTY  sample         1918976.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.90                   true        NETTY  sample         2232320.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.95                   true        NETTY  sample         2330624.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.99                   true        NETTY  sample         2729574.400                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.999                  true        NETTY  sample         6127304.704                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p0.9999                 true        NETTY  sample        15515648.000                ns/op
TransportBenchmark.unaryCall1024:unaryCall1024·p1.00                   true        NETTY  sample        15515648.000                ns/op
TransportBenchmark.unaryCall1024:·gc.alloc.rate                        true        NETTY  sample    10      2071.435 ±    141.669  MB/sec
TransportBenchmark.unaryCall1024:·gc.alloc.rate.norm                   true        NETTY  sample    10   4318096.849 ±    269.655    B/op
TransportBenchmark.unaryCall1024:·gc.churn.PS_Eden_Space               true        NETTY  sample    10      2076.282 ±    323.504  MB/sec
TransportBenchmark.unaryCall1024:·gc.churn.PS_Eden_Space.norm          true        NETTY  sample    10   4335884.918 ± 729189.378    B/op
TransportBenchmark.unaryCall1024:·gc.churn.PS_Survivor_Space           true        NETTY  sample    10         1.567 ±      1.238  MB/sec
TransportBenchmark.unaryCall1024:·gc.churn.PS_Survivor_Space.norm      true        NETTY  sample    10      3274.883 ±   2640.345    B/op
TransportBenchmark.unaryCall1024:·gc.count                             true        NETTY  sample    10        31.000               counts
TransportBenchmark.unaryCall1024:·gc.time                              true        NETTY  sample    10        51.000                   ms
2016-09-21 09:24:10 -07:00
Kun Zhang d74091f567 core: fix a discrepency in state transition.
Channel state API doesn't allow a TRANSIENT_FAILURE->IDLE edge.
Change TransportSet to always transition to CONNECTING after
TRANSIENT_FAILURE.

This behavior, combined with that it never uses IDLE_TIMEOUT to
transition from READY to IDLE, effectivly makes TransportSet
Channel-state API-compliant under an infinite IDLE_TIMEOUT.

Also set the default IDLE_TIMEOUT to 30min.
2016-09-20 21:12:43 -07:00
Kun Zhang 107fa8e801 core: Channel connectivity state API.
Add connectivity state methods on ManagedChannel.
Make TransportSet a ManagedChannel and implement channel state API.
2016-09-20 17:42:00 -07:00
ZHANG Dapeng 40c5700cc3 core: fix race condition for TransportSet scheduleBackoff
Trying to fix issue  #2188
- Try to keep avoiding the lock issue #2152 and also to avoid race condition #2188.
- Add `checkState` for `endBackoff()`. Could help hit and identify any potential issue related to #2188.
- Make sure `startBackoff()` and `endBackoff()` invoked in the right order.
- Not to schedule endBackoff if transportSet has been shutdown.
2016-09-20 11:32:38 -07:00
Carl Mastrangelo 141eed5ed0 core: change Metadata internals to avoid garbage creation
Before:
Benchmark                                                                   (headerCount)    Mode     Cnt        Score    Error  Units
InboundHeadersBenchmark.defaultHeaders_clientHandler                                  N/A    avgt      10      240.879 ±  4.903  ns/op
InboundHeadersBenchmark.defaultHeaders_serverHandler                                  N/A    avgt      10      882.354 ± 16.177  ns/op
InboundHeadersBenchmark.grpcHeaders_clientHandler                                     N/A    avgt      10      208.068 ±  5.380  ns/op
InboundHeadersBenchmark.grpcHeaders_serverHandler                                     N/A    avgt      10      477.604 ±  8.200  ns/op
OutboundHeadersBenchmark.convertClientHeaders                                           1  sample  234233      125.232 ± 11.903  ns/op
OutboundHeadersBenchmark.convertClientHeaders                                           5  sample  344367      264.343 ± 18.318  ns/op
OutboundHeadersBenchmark.convertClientHeaders                                          10  sample  392273      439.640 ±  2.589  ns/op
OutboundHeadersBenchmark.convertClientHeaders                                          20  sample  221506      855.115 ± 38.899  ns/op
OutboundHeadersBenchmark.convertServerHeaders                                           1  sample  253676      111.941 ±  2.742  ns/op
OutboundHeadersBenchmark.convertServerHeaders                                           5  sample  368499      248.255 ±  2.601  ns/op
OutboundHeadersBenchmark.convertServerHeaders                                          10  sample  390015      439.651 ± 11.040  ns/op
OutboundHeadersBenchmark.convertServerHeaders                                          20  sample  221807      840.435 ± 21.667  ns/op
OutboundHeadersBenchmark.encodeClientHeaders                                            1  sample  230139      432.866 ± 25.503  ns/op
OutboundHeadersBenchmark.encodeClientHeaders                                            5  sample  226901      765.095 ± 19.969  ns/op
OutboundHeadersBenchmark.encodeClientHeaders                                           10  sample  260495     1268.239 ± 21.850  ns/op
OutboundHeadersBenchmark.encodeClientHeaders                                           20  sample  311526     2059.973 ± 23.503  ns/op

After:

Benchmark                                                                   (headerCount)    Mode     Cnt        Score    Error  Units
InboundHeadersBenchmark.defaultHeaders_clientHandler                                  N/A    avgt      10      104.317 ±  1.973  ns/op
InboundHeadersBenchmark.defaultHeaders_serverHandler                                  N/A    avgt      10      395.666 ± 11.056  ns/op
InboundHeadersBenchmark.grpcHeaders_clientHandler                                     N/A    avgt      10       64.147 ±  4.076  ns/op
InboundHeadersBenchmark.grpcHeaders_serverHandler                                     N/A    avgt      10      228.299 ±  2.874  ns/op
OutboundHeadersBenchmark.convertClientHeaders                                           1  sample  252451      102.718 ±  2.714  ns/op
OutboundHeadersBenchmark.convertClientHeaders                                           5  sample  239976      225.812 ± 38.824  ns/op
OutboundHeadersBenchmark.convertClientHeaders                                          10  sample  258119      364.475 ± 57.217  ns/op
OutboundHeadersBenchmark.convertClientHeaders                                          20  sample  260138      676.950 ± 36.243  ns/op
OutboundHeadersBenchmark.convertServerHeaders                                           1  sample  276064      105.371 ±  1.859  ns/op
OutboundHeadersBenchmark.convertServerHeaders                                           5  sample  255128      190.970 ± 16.475  ns/op
OutboundHeadersBenchmark.convertServerHeaders                                          10  sample  272923      366.769 ± 28.204  ns/op
OutboundHeadersBenchmark.convertServerHeaders                                          20  sample  264797      641.961 ± 18.879  ns/op
OutboundHeadersBenchmark.encodeClientHeaders                                            1  sample  226078      425.262 ±  3.481  ns/op
OutboundHeadersBenchmark.encodeClientHeaders                                            5  sample  253606      675.488 ± 26.001  ns/op
OutboundHeadersBenchmark.encodeClientHeaders                                           10  sample  286556     1157.014 ± 12.923  ns/op
OutboundHeadersBenchmark.encodeClientHeaders                                           20  sample  345649     1874.806 ± 36.227  ns/op
2016-09-19 14:25:48 -07:00
ZHANG Dapeng 16c07ba434 examples: fix bound method not same as in service descriptor for HelloJsonServer
Fix the following issue.
HelloJsonServer fails to start:
````
Exception in thread "main" java.lang.IllegalStateException: Bound method for helloworld.Greeter/SayHello not same instance as method in service descriptor
    at io.grpc.ServerServiceDefinition$Builder.build(ServerServiceDefinition.java:156)
    at io.grpc.examples.advanced.HelloJsonServer.bindService(HelloJsonServer.java:131)
    at io.grpc.examples.advanced.HelloJsonServer.start(HelloJsonServer.java:70)
    at io.grpc.examples.advanced.HelloJsonServer.main(HelloJsonServer.java:105)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
````
2016-09-15 17:24:28 -07:00
Carl Mastrangelo 48b6c19072 interop-testing: skip large memory tests on constrained JVMs 2016-09-14 13:41:23 -07:00
Kun Zhang 08607466fe Fix an NPE in Status.
US_ASCII may have not been initialized when the Code enums are created,
causing an NPE and making Status class fail to load:

java.lang.ExceptionInInitializerError
        at io.grpc.Status$Code.<init>(Status.java:222)
        at io.grpc.Status$Code.<clinit>(Status.java:79)
        at io.grpc.internal.GrpcUtilTest.http2ErrorStatus(GrpcUtilTest.java:74)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:49)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:230)
        at org.junit.rules.RunRules.evaluate(RunRules.java:20)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:273)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:240)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:65)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:238)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:55)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:231)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:316)
        at com.google.testing.junit.runner.junit4.CancellableRequestFactory$CancellableRunner.run(CancellableRequestFactory.java:90)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
        at com.google.testing.junit.runner.junit4.JUnit4Runner.run(JUnit4Runner.java:112)
        at com.google.testing.junit.runner.GoogleTestRunner.runTestsInSuite(GoogleTestRunner.java:197)
        at com.google.testing.junit.runner.GoogleTestRunner.runTestsInSuite(GoogleTestRunner.java:174)
        at com.google.testing.junit.runner.GoogleTestRunner.main(GoogleTestRunner.java:133)
Caused by: java.lang.NullPointerException
        at io.grpc.Status$Code.values(Status.java:75)
        at io.grpc.Status.buildStatusList(Status.java:249)
        at io.grpc.Status.<clinit>(Status.java:245)

Strangely this only fails GrpcUtilTest.http2ErrorStatus inside google.
Now switch to use Guava Charsets.
2016-09-14 10:00:01 -07:00
Kun Zhang f24cf2a154 Remove nonsense checkNotNull().
This was missed out when switching id from Integer to int.  Detected by
internal ErrorProne.
2016-09-14 09:47:57 -07:00
Eric Anderson bb7384639b core: Remove com.google.common.collect usages, again
Commit 656e8ce (#2208) removed most usages, but missed one and one was
re-added. Since all usages are removed, it should be much easier to
notice regressions.
2016-09-14 09:04:52 -07:00
Carl Mastrangelo 1623063143 core: speed up Status code and message parsing
This introduces the idea of a "Trusted" Ascii Marshaller, which is
known to always produce valid ASCII byte arrays.  This saves a
surprising amount of garbage, since String conversion involves
creating a new java.lang.StringCoding, and a sun.nio.cs.US_ASCII.

There are other types that can be converted (notably
Http2ClientStream's :status marshaller, which is particularly
wasteful).

Before:
Benchmark                              Mode     Cnt     Score    Error  Units
StatusBenchmark.codeDecode           sample  641278    88.889 ±  9.673  ns/op
StatusBenchmark.codeEncode           sample  430800    73.014 ±  1.444  ns/op
StatusBenchmark.messageDecodeEscape  sample  433467   441.078 ± 58.373  ns/op
StatusBenchmark.messageDecodePlain   sample  676526   268.620 ±  7.849  ns/op
StatusBenchmark.messageEncodeEscape  sample  547350  1211.243 ± 29.907  ns/op
StatusBenchmark.messageEncodePlain   sample  419318   223.263 ±  9.673  ns/op

After:
Benchmark                              Mode     Cnt    Score    Error  Units
StatusBenchmark.codeDecode           sample  442241   48.310 ±  2.409  ns/op
StatusBenchmark.codeEncode           sample  622026   35.475 ±  0.642  ns/op
StatusBenchmark.messageDecodeEscape  sample  595572  312.407 ± 15.870  ns/op
StatusBenchmark.messageDecodePlain   sample  565581   99.090 ±  8.799  ns/op
StatusBenchmark.messageEncodeEscape  sample  479147  201.422 ± 10.765  ns/op
StatusBenchmark.messageEncodePlain   sample  560957   94.722 ±  1.187  ns/op

Also fixes #2237

Before:
Result "unaryCall1024":
  mean = 155710.268 ±(99.9%) 149.278 ns/op

  Percentiles, ns/op:
      p(0.0000) =  63552.000 ns/op
     p(50.0000) = 151552.000 ns/op
     p(90.0000) = 188672.000 ns/op
     p(95.0000) = 207360.000 ns/op
     p(99.0000) = 260608.000 ns/op
     p(99.9000) = 358912.000 ns/op
     p(99.9900) = 1851425.792 ns/op
     p(99.9990) = 11161178.767 ns/op
     p(99.9999) = 14985005.383 ns/op
    p(100.0000) = 17235968.000 ns/op

Benchmark                         (direct)  (transport)    Mode      Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  3205966  155710.268 ± 149.278  ns/op

After:
Result "unaryCall1024":
  mean = 147474.794 ±(99.9%) 128.733 ns/op

  Percentiles, ns/op:
      p(0.0000) =  59520.000 ns/op
     p(50.0000) = 144640.000 ns/op
     p(90.0000) = 176128.000 ns/op
     p(95.0000) = 190464.000 ns/op
     p(99.0000) = 236544.000 ns/op
     p(99.9000) = 314880.000 ns/op
     p(99.9900) = 1113084.723 ns/op
     p(99.9990) = 10783126.979 ns/op
     p(99.9999) = 13887153.242 ns/op
    p(100.0000) = 15253504.000 ns/op

Benchmark                         (direct)  (transport)    Mode      Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  3385015  147474.794 ± 128.733  ns/op
2016-09-13 13:08:59 -07:00
Jakob Buchgraber af2434375a netty: complete promise when RequestMessagesCommand 2016-09-13 21:41:56 +02:00
Eric Anderson a702102e41 Mark Thrift experimental
New APIs need a stablization period.
2016-09-12 16:49:42 -07:00
Eric Anderson 6907d81109 core: Make getTransport's fast path lock-free
This change exposed a pre-existing bug where shutdownNow wasn't called
for decommissionedTransports. The bug is fixed and a test added in this
commit.

Fixes #2120
2016-09-12 12:55:03 -07:00
Kun Zhang 3d4ae36074 Fix a deadlock in TransportSet.
Honor the lock order that transport lock > channel lock.

Resolves #2246
2016-09-12 11:11:32 -07:00
Eric Anderson 8b745d9114 core: Make PickFirst.pick's fast path lock-free
Fixes #2121
2016-09-12 10:19:09 -07:00
Jakob Buchgraber 4aadf550ee netty: Fix receipt of ClosedChannelException instead of actual error. Fixes #1330.
Our API allows pings to be send even after the transport has been shutdown. We currently
don't handle the case, where the Netty channel has been closed but the NettyClientHandler
has not yet been removed from the pipeline, correctly. That is, we need to query the shutdown
status whenever we receive a ClosedChannelException.

Also, some cleanup.
2016-09-12 19:17:34 +02:00
Jakob Buchgraber 8c18a0d355 netty: use custom http2 headers for decoding.
The DefaultHttp2Headers class is a general-purpose Http2Headers implementation
and provides much more functionality than we need in gRPC. In gRPC, when reading
headers off the wire, we only inspect a handful of them, before converting to
Metadata.

This commit introduces a Http2Headers implementation that aims for insertion
efficiency, a low memory footprint and fast conversion to Metadata.

  - Header names and values are stored in plain byte[].
  - Insertion is O(1), while lookup is now O(n).
  - Binary header values are base64 decoded as they are inserted.
  - The byte[][] returned by namesAndValues() can directly be used to construct
    a new Metadata object.
  - For HTTP/2 request headers, the pseudo headers are no longer carried over to
    Metadata.

A microbenchmark aiming to replicate the usage of Http2Headers in NettyClientHandler
and NettyServerHandler shows decent throughput gains when compared to DefaultHttp2Headers.

Benchmark                                             Mode  Cnt     Score    Error  Units
InboundHeadersBenchmark.defaultHeaders_clientHandler  avgt   10   283.830 ±  4.063  ns/op
InboundHeadersBenchmark.defaultHeaders_serverHandler  avgt   10  1179.975 ± 21.810  ns/op
InboundHeadersBenchmark.grpcHeaders_clientHandler     avgt   10   190.108 ±  3.510  ns/op
InboundHeadersBenchmark.grpcHeaders_serverHandler     avgt   10   561.426 ±  9.079  ns/op

Additionally, the memory footprint is reduced by more than 50%!

gRPC Request Headers: 864 bytes
Netty Request Headers: 1728 bytes
gRPC Response Headers: 216 bytes
Netty Response Headers: 528 bytes

Furthermore, this change does most of the gRPC groundwork necessary to be able
to cache higher ordered objects in HPACK's dynamic table, as discussed in [1].

[1] https://github.com/grpc/grpc-java/issues/2217
2016-09-09 23:15:18 +02:00
Carl Mastrangelo de9c320196 benchmarks: upgrade to jmh 1.14 2016-09-09 14:14:31 -07:00
Carl Mastrangelo e79a27dec3 core: fix a javadoc bug in ClientCall 2016-09-09 13:33:00 -07:00
Carl Mastrangelo 24de2431c7 protobuf: fast path zero sized messages 2016-09-08 18:17:07 -07:00
Carl Mastrangelo 35c3f8171b core/internal: replace make Stream id a primitive 2016-09-08 17:39:51 -07:00
Xiao Hang c69a4b8f19 core: add a new option to MethodDescriptor for caching support 2016-09-08 16:53:51 -07:00
Eric Anderson bdf8b01129 core,protobuf: Add simple argument introspection for methods
The cast required in protobuf makes me question how much I like
ReflectableMarshaller, but it seems to be pretty sound and the cast is
more an artifact of generics than the API.

Nano and Thrift were purposefully not updated, since getting just the
class requires making a new message instance. That seems a bit lame. It
probably is no burden to create an instance to get the class, and it may
not be too hard to improve the factory to provide class information, but
didn't want to bother at this point. Especially since nano users are
unlikely to need the introspection functionality.
2016-09-08 11:05:16 -07:00
Carl Mastrangelo f78644d762 core: add Metadata.discardAll()
Metadata.removeAll creates an iterator for looking through removed
values even if the call doens't use it.  This change adds a similar
method which doesn't create garbage.

This change makes it easier in the future to alter the internals
of Metadata where it may be expensive to return removed values.
2016-09-08 10:29:22 -07:00
Carl Mastrangelo 5379de726d core: fix indentation in MethodDescriptor 2016-09-07 17:40:21 -07:00
Carl Mastrangelo ca5a402fe6 netty: cache method path conversion
Benchmark                                      Mode      Cnt   Score   Error  Units
MethodDescriptorBenchmark.direct             sample  1179094  43.483 ± 0.610  ns/op
MethodDescriptorBenchmark.old                sample  1079285  66.210 ± 5.402  ns/op
MethodDescriptorBenchmark.transportSpecific  sample  1408070  36.800 ± 0.423  ns/op
2016-09-07 14:41:02 -07:00
Carl Mastrangelo 893ef44b4c all/tests: add a ClientCall and ServerCall suitable for use in tests 2016-09-02 17:09:49 -07:00
Carl Mastrangelo ea3f506249 core: avoid allocating Iterators in EquivalentAddressGroup, which is called for each new RPC
Benchmarked with 3 runs of 4 forks
Before:
Benchmark                         (direct)  (transport)    Mode     Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  255593  156248.670 ± 563.514  ns/op
Benchmark                         (direct)  (transport)    Mode     Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  261443  152753.415 ± 500.957  ns/op
Benchmark                         (direct)  (transport)    Mode     Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  258978  154205.374 ± 453.808  ns/op

After:
Benchmark                         (direct)  (transport)    Mode     Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  262194  152313.101 ± 502.563  ns/op
Benchmark                         (direct)  (transport)    Mode     Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  264811  150809.474 ± 477.459  ns/op
Benchmark                         (direct)  (transport)    Mode     Cnt       Score     Error  Units
TransportBenchmark.unaryCall1024      true        NETTY  sample  263606  151501.729 ± 593.149  ns/op
2016-09-02 15:48:23 -07:00
Kun Zhang c4f7f5c4fd core: split Context into a separate grpc-context artifact.
The Context API is not particularly gRPC-specific, and will be used by
Census as its context propagation mechanism.

Removed all dependencies to make it easy for other libraries to depend
on.
2016-09-02 13:18:35 -07:00
Kun Zhang 58d78dd0aa core: add ServerTransportFilter
Called whenever a ServerTransport is ready and terminated.  Has the
ability to modify transport attributes, which ServerCall.attributes()
are based on.

Related changes:

- Attribute keys for remote address and SSL session are now moved from
ServerCall to a neutral place io.grpc.Grpc, because they can also be
used from ServerTransportFilter, and probably will be used on the
client-side too.  The old keys on ServerCall is marked deprecated and
are equivalent to the new keys.
- Added transportReady() to ServerTransportListener.

Resolves #2132
2016-08-31 14:45:15 -07:00
Carl Mastrangelo 48c6b3d398 all/tests: unmock ClientCall and ServerCall 2016-08-30 09:58:02 -07:00
Carl Mastrangelo 3bf8d94f02 core/tests: add missing RunWith annotation 2016-08-29 12:53:52 -07:00
Carl Mastrangelo 6d28a93e21 core: simplify timeout header processing
Changes slightly improve performance

Benchmark                    (serialized)    Mode     Cnt    Score    Error  Units
GrpcUtilBenchmark.encodeNew         1000n  sample  336623   51.718 ±  1.417  ns/op
GrpcUtilBenchmark.encodeNew         1000u  sample  236574   77.555 ± 20.875  ns/op
GrpcUtilBenchmark.encodeNew         1000m  sample  224392   71.155 ±  1.600  ns/op
GrpcUtilBenchmark.encodeNew         1000S  sample  229616   67.269 ±  2.037  ns/op
GrpcUtilBenchmark.encodeNew         1000M  sample  215301   70.282 ±  1.933  ns/op
GrpcUtilBenchmark.encodeNew         1000H  sample  225063   73.679 ± 20.430  ns/op
GrpcUtilBenchmark.encodeOld         1000n  sample  311832   85.519 ±  1.729  ns/op
GrpcUtilBenchmark.encodeOld         1000u  sample  291613   92.320 ±  1.732  ns/op
GrpcUtilBenchmark.encodeOld         1000m  sample  271871   93.447 ±  1.872  ns/op
GrpcUtilBenchmark.encodeOld         1000S  sample  234932  117.956 ± 16.810  ns/op
GrpcUtilBenchmark.encodeOld         1000M  sample  224636  124.310 ± 20.249  ns/op
GrpcUtilBenchmark.encodeOld         1000H  sample  226764  130.803 ± 19.211  ns/op
GrpcUtilBenchmark.parseNew          1000n  sample  320709   60.480 ±  1.303  ns/op
GrpcUtilBenchmark.parseNew          1000u  sample  316349   64.447 ± 13.673  ns/op
GrpcUtilBenchmark.parseNew          1000m  sample  318209   61.705 ±  2.580  ns/op
GrpcUtilBenchmark.parseNew          1000S  sample  319629   59.342 ±  1.758  ns/op
GrpcUtilBenchmark.parseNew          1000M  sample  305715   59.362 ±  1.489  ns/op
GrpcUtilBenchmark.parseNew          1000H  sample  314919   60.224 ±  1.563  ns/op
GrpcUtilBenchmark.parseOld          1000n  sample  279243   64.040 ±  1.510  ns/op
GrpcUtilBenchmark.parseOld          1000u  sample  278008   71.313 ± 13.620  ns/op
GrpcUtilBenchmark.parseOld          1000m  sample  272633   67.872 ±  2.967  ns/op
GrpcUtilBenchmark.parseOld          1000S  sample  280955   63.966 ±  2.490  ns/op
GrpcUtilBenchmark.parseOld          1000M  sample  257645   71.329 ±  2.117  ns/op
GrpcUtilBenchmark.parseOld          1000H  sample  282510   68.425 ± 17.650  ns/op
2016-08-26 17:32:41 -07:00
Carl Mastrangelo 8894769cdf stub: make more classes final 2016-08-26 15:39:43 -07:00
Eric Anderson 656e8ce37f core: Remove com.google.common.collect usages for Android
This reduces the number of methods gRPC brings in by ~450, which is
substantial. Each application will see different numbers though,
depending on their usage and their other dependencies.

A very rough (under) counting for number of methods included because of
gRPC in android-interop-test is 2746, and that is reduced to 2313 (-433)
by this change. That count includes grpc, guava, okhttp, okio, and nano.
The actual reduction of methods is 447, with the discrepency due to
reduction of methods in java.util and java.lang. Of the 433 removed
methods, 377 are from com.google.common.collect and 61 from
com.google.common.base. The removal costed an increase of 5 methods
(total 1671) within io.grpc itself.
2016-08-26 15:13:45 -07:00
nmittler f254fadfbe Add RunWith annotation to AutoWindowSizingOnTest 2016-08-26 07:18:57 -07:00
Carl Mastrangelo 7c847acf57 core: clarify EOS dataframe error came from server 2016-08-25 17:59:29 -07:00
Lukasz Strzalkowski 864158bdfb core: add tests for ResolvedServerInfo 2016-08-25 16:11:40 -07:00
Carl Mastrangelo 26a08cd75e core: add DoNotMock annotations 2016-08-25 11:14:43 -07:00
Kun Zhang 7909abf065 core: remove unused code path.
writeKnownLength() is never called with compressed == true, because in
most cases it's impossible to know the size of the compressed message.
2016-08-24 15:38:49 -07:00