Commit Graph

331 Commits

Author SHA1 Message Date
Easwar Swaminathan 728364accf
server: return UNIMPLEMENTED on receipt of malformed method name (#4464) 2021-05-24 17:30:40 -07:00
Ehsan Afzali a8e85e0d57
server: allow PreparedMsgs to work for server streams (#3480) 2021-05-21 15:54:24 -07:00
Doug Fawley 328b1d171a
transport: allow InTapHandle to return status errors (#4365) 2021-05-07 14:37:52 -07:00
Mikhail Mazurskiy d2d6bdae07
server: add ForceServerCodec() to set a custom encoding.Codec on the server (#4205) 2021-05-06 09:40:54 -07:00
Easwar Swaminathan 52a707c0da
xds: serving mode changes outlined in gRFC A36 (#4328) 2021-04-26 14:29:06 -07:00
Easwar Swaminathan 2fad6bf4da
xds: Implement server-side security (#4092) 2020-12-16 10:27:18 -08:00
Gaurav Gahlot d9063e7af3
standardized experimental warnings (#3917) 2020-10-02 09:11:08 -07:00
Stephen L. White e6c98a478e
stats: include message header in stats.InPayload.WireLength (#3886) 2020-09-25 10:06:54 -07:00
Doug Fawley 44d73dff99
cmd/protoc-gen-go-grpc: rework service registration (#3828) 2020-08-25 09:28:01 -07:00
Garrett Gutierrez 0e72e09474
server: prevent hang in Go HTTP transport in some error cases (#3833) 2020-08-21 18:04:04 -07:00
Easwar Swaminathan f30caa90ad
server: Add ServiceRegistrar interface. (#3816) 2020-08-14 10:26:20 -07:00
Easwar Swaminathan a5514c9e50
grpc: Minor refactor in server code. (#3779) 2020-08-06 13:10:09 -07:00
Menghan Li c95dc4da23
doc: mark CustomCodec as deprecated (#3698) 2020-06-26 12:56:03 -07:00
Garrett Gutierrez 506b773066
Implemented component logging (#3617) 2020-06-26 12:04:47 -07:00
IceberGu 636b0d84dd
internal: fix typos (#3581) 2020-05-19 19:24:38 -07:00
Adhityaa Chandrasekar a0cdc21e61
server.go: use worker goroutines for fewer stack allocations (#3204)
Currently (go1.13.4), the default stack size for newly spawned
goroutines is 2048 bytes. This is insufficient when processing gRPC
requests as the we often require more than 4 KiB stacks. This causes the
Go runtime to call runtime.morestack at least twice per RPC, which
causes performance to suffer needlessly as stack reallocations require
all sorts of internal work such as changing pointers to point to new
addresses.

Since this stack growth is guaranteed to happen at least twice per RPC,
reusing goroutines gives us two wins:

  1. The stack is already grown to 8 KiB after the first RPC, so
     subsequent RPCs do not call runtime.morestack.
  2. We eliminate the need to spawn a new goroutine for each request
     (even though they're relatively inexpensive).

Performance improves across the board. The improvement is especially
visible in small, unary requests as the overhead of stack reallocation
is higher, percentage-wise. QPS is up anywhere between 3% and 5%
depending on the number of concurrent RPC requests in flight. Latency is
down ~3%. There is even a 1% decrease in memory footprint in some cases,
though that is an unintended, but happy coincidence.

unary-networkMode_none-bufConn_false-keepalive_false-benchTime_1m0s-trace_false-latency_0s-kbps_0-MTU_0-maxConcurrentCalls_8-reqSize_1B-respSize_1B-compressor_off-channelz_false-preloader_false
               Title       Before        After Percentage
            TotalOps      2613512      2701705     3.37%
             SendOps            0            0      NaN%
             RecvOps            0            0      NaN%
            Bytes/op      8657.00      8654.17    -0.03%
           Allocs/op       173.37       173.28     0.00%
             ReqT/op    348468.27    360227.33     3.37%
            RespT/op    348468.27    360227.33     3.37%
            50th-Lat    174.601µs    167.378µs    -4.14%
            90th-Lat    233.132µs    229.087µs    -1.74%
            99th-Lat     438.98µs    441.857µs     0.66%
             Avg-Lat    183.263µs     177.26µs    -3.28%
2020-04-23 15:50:02 -07:00
Garrett Gutierrez fff75ae40f
channelz: log on channelz trace events and trace on channelz relevant logs. (#3329)
channelz: log on channelz trace events and trace on channelz relevant logs. (#3329)
2020-02-14 10:11:26 -08:00
Doug Fawley 6b9bf4296e
Revert "profiling: add hooks within grpc (#3159)" (#3378)
This reverts commit 83263d17f7.
2020-02-14 07:56:46 -08:00
tukeJonny d0235e4d6b
interceptor: new APIs for chaining server interceptors. (#3336) 2020-02-12 11:11:50 -08:00
Adhityaa Chandrasekar 83263d17f7
profiling: add hooks within grpc (#3159) 2020-02-12 11:10:44 -08:00
Menghan Li 8c50fc2565
revert buffer reuse (#3338)
* Revert "stream: fix returnBuffers race during retry (#3293)"

This reverts commit ede71d589c.

* Revert "codec/proto: reuse of marshal byte buffers (#3167)"

This reverts commit 642675125e.
2020-01-27 13:30:41 -08:00
Menghan Li ede71d589c
stream: fix returnBuffers race during retry (#3293)
And release the buffer after Write(), unless the buffer needs to be kept for retries.
2020-01-07 17:17:22 -08:00
Adhityaa Chandrasekar 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
Adhityaa Chandrasekar 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
Doug Fawley 24f6331d7e
server: correct doc regarding unknown handlers and interceptors (#3195) 2019-11-19 14:30:36 -08:00
Mo Zhonghua fb2e5cdc85 server: add ServerOption HeaderTableSize (#2931) 2019-10-03 16:08:31 -07:00
David Zbarsky 92635fa6bf server: avoid call to trace.FromContext and resulting allocations when tracing is disabled (#2926) 2019-07-30 10:14:53 -07:00
ajwerner b5748caae7 server: populate WireLength on stats.InPayload for unary RPCs (#2932)
Fixes #2692 which was incompletely fixed by #2711.

Also adds updates stats/stat_test.go to sanity check WireLength.
2019-07-24 16:24:45 -07:00
David Zbarsky 04c71b7aac server: avoid an unnecessary allocation per-RPC for OK status (#2920) 2019-07-22 09:53:08 -07:00
Doug Fawley 59fd1f3d41
server: immediately close all connections created after GracefulStop (#2903)
Internal cleanup: replace quit/quitOnce/done/doneOnce with grpcsync.Events.
2019-07-12 13:14:19 -07:00
Can Guler 915d20dcdb
grpc: change type of Server.conns
Change Server.conns from a map[io.Closer]bool to a map[transport.ServerTransport]bool.
2019-06-26 11:09:45 -07:00
Menghan Li 1e6ab1e96e
server: define ServerOption as interfaces (#2784)
Instead of functions. So custom server options can be made by wrapping an
EmptyServerOption.
2019-04-26 10:33:22 -07:00
David Symonds f1437f7cc5 server: Improve error message when an unknown method is invoked. (#2723)
Previously only `unknown service <x>` was returned, which is misleading
when the service is known but the method is unknown.
2019-03-27 16:19:28 -07:00
David Symonds 9a2caafd93 client: restore remote address in traces (#2718)
The client-side traces were otherwise only showing `RPC: to <nil>`,
which is not helpful.

Also clean up construction of traceInfo and firstLine in a few places.
2019-03-27 09:52:40 -07:00
JP Sugarbroad a618c37a27 server: Don't log errors on ErrConnDispatched (#2656)
ErrConnDispatched is a normal error -- we should not fill up logs with it.
2019-03-07 13:22:17 -08:00
Doug Fawley ed70822b12 keepalive: apply minimum ping time of 10s to client and 1s to server (#2642)
* keepalive: apply minimum ping time of 10s to client and 1s to server

* review fixes
2019-02-21 13:09:37 -08:00
Wu Kai 4cad6a6283 comment: default MaxSendMsgSize should be math.MaxInt32 instead of 4MB (#2586) 2019-01-22 10:48:59 -08:00
Doug Fawley dfd7708d35
cleanup: use time.Until(t) instead of t.Sub(time.Now) (#2571) 2019-01-15 16:09:50 -08:00
Doug Fawley 04ea82009c
cleanup: replace "x/net/context" import with "context" (#2439) 2018-11-12 13:30:41 -08:00
Menghan Li 24638f5984
binarylog: call binary log in Client and Server (#2388)
Also includes:
 - Export `NewLoggerFromConfigString` so it can be also used when config string is specified in another way (e.g. command line flag)
 - Export `Logger` so user can install custom sink
 - Add temp file sink implementation
2018-10-31 10:21:20 -07:00
Menghan Li c4d3b2fa07
channelz: register sockets with meaningful refnames (#2416) 2018-10-30 16:28:48 -07:00
Menghan Li dfaadfecca
server: handleStream() cleanup (#2352) 2018-10-15 13:27:22 -07:00
Menghan Li 0361d80ffd
server: reuse function recv() in processUnary (#2351)
This change splits recv() into two functions so it can be used by processUnary.
2018-10-08 13:55:04 -07:00
Menghan Li 59dd9b3f19
test: add go 1.11 to travis and remove go 1.7 (#2278) 2018-08-27 13:31:20 -07:00
lyuxuan 07ef407d99
channelz: unexport unnecessary API on grpc entities (#2257) 2018-08-06 16:02:47 -07:00
lyuxuan f4da7eee53
channelz: use atomic instead of mutex (#2218) 2018-08-06 11:17:12 -07:00
dfawley a344a35754
internal: remove TestingUseHandlerImpl (#2253) 2018-08-03 09:35:00 -07:00
dfawley 339b6cb107
transport: eliminate StreamError; use status errors instead (#2239) 2018-07-26 10:30:58 -07:00
dfawley e193757038
internal/transport: remove some unused fields from structs (#2213)
- Flush and Authority are never read by the transport.
- Authority is used indirectly; move it to dialOptions.
- Delay is only set to false.
2018-07-13 09:56:47 -07:00
dfawley 11b582728a
transport: move to internal to make room for new, public transport API (#2212)
This is a breaking change, but the transport package was never intended for use outside of grpc.  Any current users that we are aware of are incorrect or have a preferred alternative.
2018-07-11 11:22:45 -07:00
lyuxuan 264daa2be4
Set and respect HTTP/2 SETTINGS_MAX_HEADER_LIST_SIZE (#2084) 2018-07-09 11:27:58 -07:00
mmukhi 3ec535a269
client, server: update dial/server buffer options to support a "disable" setting (#2147) 2018-06-27 11:16:33 -07:00
lyuxuan 7268ca41d3
channelz: stage 4 - add security and socket option info with appengine build tags (#2149) 2018-06-25 10:32:20 -07:00
lyuxuan b28608a9db
channelz: move APIs to internal except channelz service (#2157) 2018-06-18 17:59:08 -07:00
lyuxuan 96cefb43cf Revert " channelz: stage 4 - add security and socket option info" (#2124)
Reverts grpc/grpc-go#2098

Appengine will fail with the error below:
```
go-app-builder: Failed parsing input: parser: bad import "syscall" in google.golang.org/grpc/channelz/funcs.go from GOPATH
```

The root cause of it is in type_linux.go.
629f6bc5e5/channelz/types_linux.go (L21-L25)
2018-06-05 18:04:12 -07:00
lyuxuan c1a21e22a6
channelz: stage 4 - add security and socket option info (#2098) 2018-06-05 13:50:19 -07:00
Menghan Li d33a923190
Revert "channelz: stage 4 - add security and socket option info" (#2096)
This reverts commit 7cc2837209.

The PR breaks darwin builds

src/google.golang.org/grpc/channelz/types_unix.go:35:15: undefined: unix.TCPInfo
2018-05-22 15:31:57 -07:00
lyuxuan 7cc2837209
channelz: stage 4 - add security and socket option info (#1965) 2018-05-22 13:32:02 -07:00
dfawley 091a800143
split encode into three functions (#2058) 2018-05-11 13:47:10 -07:00
mmukhi 0bc7c3280e
Revert "Less mem (#1987)" (#2049)
This reverts commit 7a8c989507.
2018-05-03 11:37:59 -07:00
mmukhi 3592bccfd9
interop: Fix unimplemented method test (#2040)
* Don't send nil requests.

* Fix import name and get rid of condition.

* Let registered encoder deal with nil requests.

* Break encode into encode and compress.
2018-05-02 16:08:12 -07:00
Chyroc f8dbc38bdc Fix "deprecated" function godoc comments to match standard formatting (#2027) 2018-05-02 08:52:49 -07:00
mmukhi 7a8c989507
Less mem (#1987)
* Export changes to OSS.

* First commit.

* Cherry-pick.

* Documentation.

* Post review updates.
2018-04-30 09:54:33 -07:00
dfawley fc37cf1364 server: export ServerTransportStreamFromContext for unary interceptors to control headers/trailers (#2019) 2018-04-26 17:38:15 -07:00
lyuxuan 4166ea7dad
Stage 2: Channelz metric collection (#1909) 2018-04-23 11:22:25 -07:00
lyuxuan 7f73c863c0
Channelz: Entity Registration and Deletion (#1811) 2018-04-09 11:13:06 -07:00
dfawley 2eae9d0c74
server: add grpc.Method function for extracting method from context (#1961) 2018-04-02 13:08:04 -07:00
Joshua Humphries 57640c0e6f Allow storing alternate transport.ServerStream implementations in context (#1904) 2018-03-20 17:02:32 -07:00
Brian Tiger Chow 2c2d834e8e stats: add BeginTime to stats.End (#1907) 2018-03-12 09:16:36 -07:00
Jean de Klerk 9aba04495f server: Convert all non-status errors to codes.Unknown (#1881)
- convertCode utilized errors that were not allowed by the library per 9d0bc30edb/doc/statuscodes.md
- Relevant issue: #1672
2018-03-08 13:46:26 -08:00
Eric 7646b5360d transport: support stats.Handler in serverHandlerTransport (#1840) 2018-02-06 10:11:40 -08:00
dfawley 5ba054bf37
encoding: Introduce new method for registering and choosing codecs (#1813) 2018-01-23 11:39:40 -08:00
dfawley 09fc336d84
server: fix bug preventing Serve from exiting when Listener is closed (#1765) 2017-12-22 12:42:04 -08:00
dfawley 2720857d97
server: fix race between GracefulStop and new incoming connections (#1745)
New connections can race with GracefulStop such that the server will accept the connection, but then close it immediately. If a connection is accepted before GracefulStop has a chance to effectively cancel the listeners, the server should handle it to avoid client errors.
2017-12-18 15:38:51 -08:00
Daniel Nephin 4e393e0b21 grpc: fix deprecation comments to conform to standard (#1691) 2017-12-18 09:23:42 -08:00
dfawley 816fa5b06f
Add proper support for 'identity' encoding type (#1664) 2017-11-17 09:24:54 -08:00
Elliot Wright 5f2e2f999e Corrected documentation on Server.Serve (#1668) 2017-11-13 13:37:12 -08:00
dfawley 8ff8683602
Implement transparent retries for gRFC A6 (#1597) 2017-11-06 13:45:11 -08:00
dfawley 551f295763
server: add EXPERIMENTAL tag to grpc.ConnectTimeout (#1652) 2017-11-06 10:29:48 -08:00
dfawley 4318e6475c
server: apply deadline to new connections until all handshaking is completed (#1646) 2017-11-03 13:53:17 -07:00
Zhouyihai Ding 5db344a40a Introduce new Compressor/Decompressor API (#1428) 2017-10-31 10:21:13 -07:00
dfawley c5f391bd6c Revert "cap max msg size to min(max_int, max_uint32) (#1598)" (#1619)
This reverts commit 5856538706.
2017-10-25 10:31:00 -07:00
lyuxuan 5856538706 cap max msg size to min(max_int, max_uint32) (#1598) 2017-10-24 10:20:54 -07:00
Shangpeng Sun 473b14250d Serve() should not return error on Stop() or GracefulStop() (#1485)
* Serve() should not return error on Stop() or GracefulStop()
* Block Serve() until Stop() or GracefulStop() returns
2017-10-18 15:27:24 -07:00
田欧 faebfcb7bf Remove single-entry var blocks (#1589) 2017-10-18 09:59:23 -07:00
dfawley 5279edf262 Update UnknownServiceHandler comment to be clearer about interceptor behavior (#1566) 2017-10-05 16:17:40 -07:00
mmukhi 8214c28a62 Make IO Buffer size configurable. (#1544)
* Make IO Buffer size configurable.

* Fixing typo
2017-09-28 14:11:14 -07:00
mmukhi 894322f00c Dedicated goroutine for writing. (#1498) 2017-09-14 13:44:14 -07:00
ZhouyihaiDing 01089b2972 Remove buf copy when the compressor exist (#1427) 2017-08-25 12:26:38 -07:00
lyuxuan 9d99afc2fd Automatic WriteStatus for RecvMsg/SendMsg error on server side (#1409)
automatically WriteStatus if there's any error when RecvMsg/SendMsg on server side.
2017-08-14 12:24:23 -07:00
dfawley 73041be906 Add 'experimental' note to ServeHTTP godoc (#1429) 2017-08-08 08:58:35 -07:00
Brad Fitzpatrick 383b11435b Document Server.ServeHTTP (#1406)
Fixes #549
2017-08-07 13:10:34 -07:00
Menghan Li d6723916d2 Use log severity and verbosity level (#1340)
- All logs use 1 severity level instead of printf
 - All transport logs only go to verbose level 2+
 - The default logger only log errors and verbosity level 1
 - Add environment variable GRPC_GO_LOG_SEVERITY_LEVEL and GRPC_GO_LOG_VERBOSITY_LEVEL to set severity or verbosity levels for the default logger
2017-07-13 12:10:19 -07:00
Peter Mattis 57ff3285cf Catch invalid use of Server.RegisterService after Register.Serve (#828) 2017-06-26 10:39:47 -07:00
Jan Tattermusch ddbf6c46a6 autofix license notice 2017-06-08 14:42:19 +02:00
MakMukhi 6fecf2831a Reopening: Server shouldn't Fatalf in case it fails to encode. (#1276)
* Server shouldn't Fatalf in case it fails to encode.
2017-06-02 12:32:37 -07:00
MakMukhi 843116533a Revert "Server shouldn't Fatalf in case it fails to encode. (#1251)" (#1274)
This reverts commit d5bc85c1e9.
2017-06-01 12:34:28 -07:00
MakMukhi d5bc85c1e9 Server shouldn't Fatalf in case it fails to encode. (#1251)
* Server shouldn't Fatalf in case it fails to encode.

* golint

* post-review update
2017-06-01 11:57:45 -07:00
lyuxuan 9f919f7b81 Merge pull request #1165 from lyuxuan/service_config_pr
Expand service config support
2017-05-22 11:15:26 -07:00
Alexander Morozov 9bf8ea0a82 clientconn, server: replace time.After with time.NewTimer (#998)
When timeout is not hit `time.After` will leak unnecessary timer, so
it's better to stop timer explicitly.

Signed-off-by: Alexander Morozov <lk4d4math@gmail.com>
2017-05-19 15:57:10 -07:00