Commit Graph

22 Commits

Author SHA1 Message Date
Carl Mastrangelo 3a39b81cf5
all: remove java6 type args 2019-02-04 10:03:50 -08:00
ZHANG Dapeng df21e40285
all: fix lint 2019-01-02 15:28:44 -08:00
Carl Mastrangelo 13ca42aff6
protobuf{,lite,nano}: make more classes final
- Split anonymous classes in named and final classes
- Fix some Javadocs and annotate when things were added.
2018-06-19 15:30:12 -07:00
Carl Mastrangelo 60a0b0c471
all: normalize copyright header 2018-05-03 14:55:21 -07:00
ZHANG Dapeng e03fe6a374
protobuf-lite: should not have dependency on core_internal 2018-01-04 14:00:25 -08:00
zpencer 2b1363d586 core,netty,okhttp,protobuf-lite: avoid @Beta guava classes (#3463) 2017-09-14 19:39:06 -07:00
Carl Mastrangelo a53d030b5c core: fix lint warnings 2017-08-25 11:23:03 -07:00
Vladimir Gordiychuk ca7685ef50 protobuf-lite: ProtoLiteUtils fix infinite loop
InputStream by contract can return zero if requested length equal to zero.

```
If len is zero, then no bytes are read and 0 is returned;
otherwise, there is an attempt to read at least one byte.
If no byte is available because the stream is at end of file,
the value -1 is returned; otherwise, at least one byte is read
and stored into b.
```

Close #3323
2017-08-15 16:04:24 -07:00
Carl Mastrangelo 166108a943 all: fix licence whitespace 2017-06-01 14:28:37 -07:00
Carl Mastrangelo 3bfd630bff all: update to Apache 2 licence
Also, update the authors.
2017-05-31 13:29:01 -07:00
kenji yoshida 17b74c1452 protobuf-lite: fix typo. s/Marhsaller/Marshaller 2017-05-14 14:19:47 -07:00
ZHANG Dapeng bb978bac31 doc: initiate some package javadoc
Initated package javadoc for 
* `io.grpc.stub`, 
* `io.grpc.auth`, 
* `io.grpc.util`, 
* `io.grpc.protobuf`, 
* `io.grpc.protobuf.lite`,
* `io.grpc.protobuf.nano`
2017-05-10 11:29:07 -07:00
Carl Mastrangelo 89bc2cd3b2 all: update to latest import ordering 2017-01-26 13:43:06 -08: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
Carl Mastrangelo 24de2431c7 protobuf: fast path zero sized messages 2016-09-08 18:17:07 -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 c47d948a47 protobuf: copy input data before decoding
CodedInputStream is risk averse in ways that hurt performance when
parsing large messages.  gRPC knows how large the input size is as it
is being read from the wire, and only tries to parse it once the entire
message has been read in.  The message is represented as chunks of
memory strung together in a CompositeReadableBuffer, and then wrapped
in a custom BufferInputStream.

When passed to Protobuf, CodedInputStream attempts to read data out
of this InputStream into CIS's internal 4K buffer.  For messages that
are much larger, CIS copies from the input in chunks of 4K and saved in
an ArrayList.  Once the entire message size is read in, it is re-copied
into one large byte array and passed back up.  This only happens for
ByteStrings and ByteBuffers that are read out of CIS.  (See
CIS.readRawBytesSlowPath for implementation).

gRPC doesn't need this overhead, since we already have the entire
message in memory, albeit in chunks.  This change copies the composite
buffer into a single heap byte buffer, and passes this (via
UnsafeByteOperations) into CodedInputStream.  This pays one copy to
build the heap buffer, but avoids the two copes in CIS.  This also
ensures that the buffer is considered "immutable" from CIS's point of
view.

Because CIS does not have ByteString aliasing turned on, this large
buffer will not accidentally be kept in memory even if only tiny fields
from the proto are still referenced.  Instead, reading ByteStrings out
of CIS will always copy.  (This copy, and the problems it avoids, can
be turned off by calling CIS.enableAliasing.)

Benchmark results will come shortly, but initial testing shows
significant speedup in throughput tests.  Profiling has shown that
copying memory was a large time consumer for messages of size 1MB.
2016-08-17 15:45:21 -07:00
Eric Anderson 65dd5db5e3 protolite: Use 'unused' variable to avoid CheckReturnValue
Internally toByteArray is annotated with CheckReturnValue, which can
cause a failure during compilation if the value is ignored.
2016-05-20 09:46:46 -07:00
Carl Mastrangelo bc661e7fbb all: Finish adding tracking issues for ExperimentalApi 2016-05-03 16:15:57 -07:00
Carl Mastrangelo 702518af22 Allow use of a global ExtensionRegistry 2016-04-15 17:36:45 -07:00
Eric Anderson 99a6d8de27 Add native support for Protobuf Lite
Lite already worked by using the protobuf project, but would bring in
extra dependencies that are not intended to work with lite. Although
protobuf is not yet providing a lite package on Maven Central, we will
be able to swap to it once it is available.

There isn't any new original code in the Java portion, except for a new
overload in ProtoUtils that accepts Message instead of MessageLite.
Depending on Message in ProtoUtils allows us to support extra features
out-of-the-box without any changes to the generated code. For example,
JSON encoding could be supported in this way if Marshaller is enhanced.

However, now codegen must be aware of Lite in order to choose with Util
class to use. That is new code.
2016-03-22 15:40:51 -07:00