From 69c76acb261b2f3a801b756ad8fabb924fd74677 Mon Sep 17 00:00:00 2001 From: Vitalii Levitskii Date: Thu, 14 Dec 2023 09:53:04 +0100 Subject: [PATCH 1/5] Back to development --- CHANGELOG.md | 4 ++++ version.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b51ce08b2..3c5f71e58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ======= +## [Unreleased] +- No changes yet. + ## [1.71.0] - 2023-12-14 - tchannel: optional transport-level config to allow reusing a buffer for reading a tchannel response body. - grpc: returned outbound response body is no longer writable. @@ -1493,6 +1496,7 @@ This release requires regeneration of ThriftRW code. ## 0.1.0 - 2016-08-31 - Initial release. +[Unreleased]: https://github.com/yarpc/yarpc-go/compare/v1.71.0...HEAD [1.71.0]: https://github.com/yarpc/yarpc-go/compare/v1.70.4...v1.71.0 [1.70.4]: https://github.com/yarpc/yarpc-go/compare/v1.70.3...v1.70.4 [1.70.3]: https://github.com/yarpc/yarpc-go/compare/v1.70.2...v1.70.3 diff --git a/version.go b/version.go index 9dea6ae0d..9f1158b02 100644 --- a/version.go +++ b/version.go @@ -21,4 +21,4 @@ package yarpc // import "go.uber.org/yarpc" // Version is the current version of YARPC. -const Version = "1.71.0" +const Version = "1.71.0-dev" From a47847aa86e03fc882546935ba6abce83f49fa48 Mon Sep 17 00:00:00 2001 From: Vitalii Date: Wed, 10 Jan 2024 13:38:24 +0300 Subject: [PATCH 2/5] Removed gonum.org/v1/gonum dep; called go mod tidy. (#2242) Signed-off-by: Vitalii Levitskii --- CHANGELOG.md | 2 +- encoding/thrift/benchmark_test.go | 45 ++++++++++++------------------- go.mod | 3 +-- go.sum | 4 --- 4 files changed, 19 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c5f71e58..879583d8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ======= ## [Unreleased] -- No changes yet. +- Removed gonum.org/v1/gonum dependency. ## [1.71.0] - 2023-12-14 - tchannel: optional transport-level config to allow reusing a buffer for reading a tchannel response body. diff --git a/encoding/thrift/benchmark_test.go b/encoding/thrift/benchmark_test.go index d1b6b9e85..c4697a29c 100644 --- a/encoding/thrift/benchmark_test.go +++ b/encoding/thrift/benchmark_test.go @@ -18,7 +18,6 @@ import ( "go.uber.org/yarpc/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalueclient" "go.uber.org/yarpc/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalueserver" "go.uber.org/yarpc/transport/tchannel" - "gonum.org/v1/gonum/stat/distuv" ) const ( @@ -26,23 +25,6 @@ const ( _kvClient = "caller" ) -type generator struct { - norm distuv.Normal - min int - max int -} - -func (g generator) next() int { - out := int(g.norm.Rand()) - if out < g.min { - out = 0 - } - if out > g.max { - out = g.max - } - return out -} - func BenchmarkThriftClientCallNormalDist(b *testing.B) { handler := &keyValueHandler{} serverAddr := newKeyValServer(b, handler) @@ -51,20 +33,14 @@ func BenchmarkThriftClientCallNormalDist(b *testing.B) { clientWithReuse := newKeyValueClient(b, serverAddr, true) // Create a normal distribution - g := generator{ - norm: distuv.Normal{ - Mu: 3 * 1024, // 3KB - Sigma: 10000, - }, - min: 0, - max: 2 * 1024 * 1024, // 2MB - } + // deviation 10k, mean 3KB, minimum 0, maximum 2MB + g := createNormalDistribution(3*1024, 10_000, 0, 2*1024*1024) var samples []string for i := 0; i < 10000; i++ { key := "foo" + strconv.FormatInt(int64(i), 10) - len := g.next() - value := generateRandomString(len) + length := g() + value := generateRandomString(length) samples = append(samples, value) handler.SetValue(context.Background(), &key, &value) } @@ -172,3 +148,16 @@ func newKeyValueClient(t testing.TB, serverAddr string, enableBufferReuse bool) t.Cleanup(func() { assert.NoError(t, dispatcher.Stop(), "could not stop dispatcher") }) return client } + +func createNormalDistribution(mean, deviation float64, minimum, maximum int) func() int { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + return func() int { + n := int(r.NormFloat64()*mean + deviation) + + // 0 <= n <= 2MB + n = max(n, minimum) + n = min(n, maximum) + + return n + } +} diff --git a/go.mod b/go.mod index 7ee00f40d..1fbf9f4d2 100644 --- a/go.mod +++ b/go.mod @@ -31,7 +31,6 @@ require ( golang.org/x/lint v0.0.0-20200130185559-910be7a94367 golang.org/x/net v0.14.0 golang.org/x/tools v0.7.0 - gonum.org/v1/gonum v0.14.0 google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 google.golang.org/grpc v1.40.1 google.golang.org/protobuf v1.26.0 @@ -47,6 +46,7 @@ require ( github.com/cespare/xxhash/v2 v2.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/structtag v1.2.0 // indirect + github.com/google/go-cmp v0.5.8 // indirect github.com/jessevdk/go-flags v1.4.0 // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect github.com/kr/pretty v0.2.0 // indirect @@ -62,7 +62,6 @@ require ( github.com/uber-common/bark v1.2.1 // indirect github.com/uber/jaeger-lib v2.4.1+incompatible // indirect go.uber.org/dig v1.8.0 // indirect - golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect golang.org/x/mod v0.9.0 // indirect golang.org/x/sys v0.11.0 // indirect diff --git a/go.sum b/go.sum index 607d8f1fa..7d8fc4e8d 100644 --- a/go.sum +++ b/go.sum @@ -228,8 +228,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug= -golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM= golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -313,8 +311,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -gonum.org/v1/gonum v0.14.0 h1:2NiG67LD1tEH0D7kM+ps2V+fXmsAnpUeec7n8tcr4S0= -gonum.org/v1/gonum v0.14.0/go.mod h1:AoWeoz0becf9QMWtE8iWXNXc27fK4fNeHNf/oMejGfU= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= From 0c3fb5ee4df663cf2a6f0900c483945e31244bbb Mon Sep 17 00:00:00 2001 From: Justin Hwang Date: Wed, 14 Feb 2024 11:59:07 -0500 Subject: [PATCH 3/5] encoding/protobuf: Update BuildProcedures slice capacity hint (#2243) --- encoding/protobuf/protobuf.go | 2 +- encoding/protobuf/v2/protobuf.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/encoding/protobuf/protobuf.go b/encoding/protobuf/protobuf.go index f6baa7c58..2a15f4da2 100644 --- a/encoding/protobuf/protobuf.go +++ b/encoding/protobuf/protobuf.go @@ -76,7 +76,7 @@ type BuildProceduresStreamHandlerParams struct { // BuildProcedures builds the transport.Procedures. func BuildProcedures(params BuildProceduresParams) []transport.Procedure { - procedures := make([]transport.Procedure, 0, 2*(len(params.UnaryHandlerParams)+len(params.OnewayHandlerParams))) + procedures := make([]transport.Procedure, 0, 2*(len(params.UnaryHandlerParams)+len(params.OnewayHandlerParams)+len(params.StreamHandlerParams))) for _, unaryHandlerParams := range params.UnaryHandlerParams { procedures = append( procedures, diff --git a/encoding/protobuf/v2/protobuf.go b/encoding/protobuf/v2/protobuf.go index b6777c8d7..d9a5f75cf 100644 --- a/encoding/protobuf/v2/protobuf.go +++ b/encoding/protobuf/v2/protobuf.go @@ -65,7 +65,7 @@ type BuildProceduresStreamHandlerParams struct { // BuildProcedures builds the transport.Procedures. func BuildProcedures(params BuildProceduresParams) []transport.Procedure { - procedures := make([]transport.Procedure, 0, 2*(len(params.UnaryHandlerParams)+len(params.OnewayHandlerParams))) + procedures := make([]transport.Procedure, 0, 2*(len(params.UnaryHandlerParams)+len(params.OnewayHandlerParams)+len(params.StreamHandlerParams))) for _, unaryHandlerParams := range params.UnaryHandlerParams { procedures = append( procedures, From 48e16a447441a2815429124477b4d3d7286763ba Mon Sep 17 00:00:00 2001 From: Richa Tibrewal Date: Wed, 21 Feb 2024 02:09:54 -0800 Subject: [PATCH 4/5] Enable rpc-caller-procedure via outbound middleware (#2240) --- CHANGELOG.md | 3 ++- internal/firstoutboundmiddleware/middleware.go | 13 +++++++++++++ internal/firstoutboundmiddleware/middleware_test.go | 6 +++--- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 879583d8f..84ccbc2fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ======= ## [Unreleased] - Removed gonum.org/v1/gonum dependency. +- Enable rpc-caller-procedure via yarpc outbound middleware. ## [1.71.0] - 2023-12-14 - tchannel: optional transport-level config to allow reusing a buffer for reading a tchannel response body. @@ -17,7 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [1.70.4] - 2023-08-31 - logging: fix logged error in observability middleware when fields of transport.Request is in the tagsBlocklist - `go.mod`: update minimum requirements to go1.21 instead of go1.14 and update `golang.org/x/net v0.7.0` to v0.14.0 -- middleware stack usage: remove ~2KB of stack usage from the rpc handler function, +- middleware stack usage: remove ~2KB of stack usage from the rpc handler function, so that it decreases the chance of needing more stack. It can improve the performance of the application. diff --git a/internal/firstoutboundmiddleware/middleware.go b/internal/firstoutboundmiddleware/middleware.go index 565138820..d6533ea65 100644 --- a/internal/firstoutboundmiddleware/middleware.go +++ b/internal/firstoutboundmiddleware/middleware.go @@ -26,6 +26,7 @@ package firstoutboundmiddleware import ( "context" + "go.uber.org/yarpc/api/encoding" "go.uber.org/yarpc/api/middleware" "go.uber.org/yarpc/api/transport" ) @@ -73,6 +74,12 @@ func update(ctx context.Context, req *transport.Request, out transport.Outbound) if namer, ok := out.(transport.Namer); ok { req.Transport = namer.TransportName() } + + // Update the caller procedure to the current procedure making this request + call := encoding.CallFromContext(ctx) + if call != nil { + req.CallerProcedure = call.Procedure() + } } func updateStream(ctx context.Context, req *transport.StreamRequest, out transport.Outbound) { @@ -85,4 +92,10 @@ func updateStream(ctx context.Context, req *transport.StreamRequest, out transpo if namer, ok := out.(transport.Namer); ok { req.Meta.Transport = namer.TransportName() } + + // Update the caller procedure to the current procedure making this request + call := encoding.CallFromContext(ctx) + if call != nil { + req.Meta.CallerProcedure = call.Procedure() + } } diff --git a/internal/firstoutboundmiddleware/middleware_test.go b/internal/firstoutboundmiddleware/middleware_test.go index aca47fdb8..830289ef5 100644 --- a/internal/firstoutboundmiddleware/middleware_test.go +++ b/internal/firstoutboundmiddleware/middleware_test.go @@ -54,7 +54,7 @@ func TestFirstOutboundMidleware(t *testing.T) { require.NoError(t, err) assert.Equal(t, "fake", string(req.Transport)) - assert.Equal(t, "", string(req.CallerProcedure)) + assert.Equal(t, "ABC", string(req.CallerProcedure)) }) t.Run("oneway", func(t *testing.T) { @@ -66,7 +66,7 @@ func TestFirstOutboundMidleware(t *testing.T) { require.NoError(t, err) assert.Equal(t, "fake", string(req.Transport)) - assert.Equal(t, "", string(req.CallerProcedure)) + assert.Equal(t, "ABC", string(req.CallerProcedure)) }) t.Run("stream", func(t *testing.T) { @@ -78,6 +78,6 @@ func TestFirstOutboundMidleware(t *testing.T) { require.NoError(t, err) assert.Equal(t, "fake", string(streamReq.Meta.Transport)) - assert.Equal(t, "", string(streamReq.Meta.CallerProcedure)) + assert.Equal(t, "ABC", string(streamReq.Meta.CallerProcedure)) }) } From b955c602e3c1abf4b8838053f31020bbd500add9 Mon Sep 17 00:00:00 2001 From: Vitalii Levitskii Date: Wed, 21 Feb 2024 18:17:58 +0800 Subject: [PATCH 5/5] Preparing release v1.72.0 --- CHANGELOG.md | 4 ++-- version.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84ccbc2fd..130d7b832 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ======= -## [Unreleased] +## [1.72.0] - 2024-02-21 - Removed gonum.org/v1/gonum dependency. - Enable rpc-caller-procedure via yarpc outbound middleware. @@ -1497,7 +1497,7 @@ This release requires regeneration of ThriftRW code. ## 0.1.0 - 2016-08-31 - Initial release. -[Unreleased]: https://github.com/yarpc/yarpc-go/compare/v1.71.0...HEAD +[1.72.0]: https://github.com/yarpc/yarpc-go/compare/v1.71.0...v1.72.0 [1.71.0]: https://github.com/yarpc/yarpc-go/compare/v1.70.4...v1.71.0 [1.70.4]: https://github.com/yarpc/yarpc-go/compare/v1.70.3...v1.70.4 [1.70.3]: https://github.com/yarpc/yarpc-go/compare/v1.70.2...v1.70.3 diff --git a/version.go b/version.go index 9f1158b02..158408949 100644 --- a/version.go +++ b/version.go @@ -21,4 +21,4 @@ package yarpc // import "go.uber.org/yarpc" // Version is the current version of YARPC. -const Version = "1.71.0-dev" +const Version = "1.72.0"