Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade gRPC to 1.38.x #3056

Merged
merged 12 commits into from
Jun 8, 2021
Merged

Conversation

pavolloffay
Copy link
Member

@pavolloffay pavolloffay commented Jun 4, 2021

Builds on top of #2857

Resolves #2771
Resolves #2172

proto-gen/api_v2/codec.go Outdated Show resolved Hide resolved
)

func init() {
encoding.RegisterCodec(newCodec())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bogdandrutu or @tigrannajaryan could you please loop in here? This PR updates to the latest gRPC and protobuf.

Jaeger uses gogo proto as OTELcol and it uses the same features - custom type for IDs and nonullable fields. To make this with the latest dependencies this codes registration is needed. I could not find the custom codec registration in OTELcol. Do you know why it is not needed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know why it is not needed?

I am not very familiar with this specific functionality of gogo, I don't know the answer to this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for looking at this. The answer why it works in the collector is here #3056 (comment)

@pavolloffay pavolloffay marked this pull request as ready for review June 5, 2021 12:21
@pavolloffay pavolloffay requested a review from a team as a code owner June 5, 2021 12:21
@pavolloffay pavolloffay requested a review from vprithvi June 5, 2021 12:21
@pavolloffay pavolloffay force-pushed the grpc1.36 branch 2 times, most recently from e09a071 to 1e614d2 Compare June 5, 2021 12:28
@codecov
Copy link

codecov bot commented Jun 5, 2021

Codecov Report

Merging #3056 (3122fab) into master (013ecf2) will decrease coverage by 0.10%.
The diff coverage is 94.73%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3056      +/-   ##
==========================================
- Coverage   95.97%   95.86%   -0.11%     
==========================================
  Files         229      233       +4     
  Lines        9956    10057     +101     
==========================================
+ Hits         9555     9641      +86     
- Misses        330      345      +15     
  Partials       71       71              
Impacted Files Coverage Δ
cmd/collector/app/zipkin/http_handler.go 97.97% <ø> (ø)
cmd/query/app/grpc_handler.go 97.33% <ø> (ø)
plugin/storage/grpc/shared/plugin.go 0.00% <ø> (ø)
plugin/storage/memory/memory.go 100.00% <ø> (ø)
cmd/agent/app/reporter/grpc/builder.go 94.23% <80.00%> (-1.61%) ⬇️
pkg/gogocodec/codec.go 100.00% <100.00%> (ø)
pkg/discovery/grpcresolver/grpc_resolver.go 98.21% <0.00%> (-1.79%) ⬇️
...ugin/sampling/strategystore/adaptive/aggregator.go 54.76% <0.00%> (ø)
plugin/sampling/strategystore/adaptive/span.go 93.54% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 013ecf2...3122fab. Read the comment docs.

@pavolloffay
Copy link
Member Author

This is ready for review/merge

Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Copy link
Contributor

@jpkrohling jpkrohling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have a review from someone with more experience with gRPC/Gogo, as I don't really understand how proto-gen/codec.go fixes our problems.

In any case, is this something we'd want for the long-term, or do you think we still need a better solution in the future?

@@ -123,3 +125,12 @@ func (b *ConnBuilder) CreateConnection(logger *zap.Logger, mFactory metrics.Fact

return conn, nil
}

// generateAndRegisterManualResolver was removed from grpc.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did they mention why it was removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems they leave the work for the caller.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should move to WithResolver?

grpc/grpc-go#3960

Not much info about why it was removed here.

proto-gen/codec.go Outdated Show resolved Hide resolved
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
@pavolloffay
Copy link
Member Author

In any case, is this something we'd want for the long-term, or do you think we still need a better solution in the future?

correct, this is rather a short-term solution. Since the gogo is compatible only with go proto V1 and it will not be made compatible with v2 we will have to migrate. It seems that solutions like https://github.com/planetscale/vtprotobuf (based on gogo/protobuf#691 (comment)) will be way forward. It is a plugin for proto compiler that generates serialization methods, it does not modify generated model classes.
This has a couple of implications for us:

  • no support for nonnullable fields
  • no support for custom types e.g. (TraceID)

Signed-off-by: Pavol Loffay <[email protected]>
@pavolloffay
Copy link
Member Author

@joe-elliott / @yurishkuro could you please review?

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try running a ser/deser benchmark before this upgrade and after?

go.mod Outdated Show resolved Hide resolved
"github.com/jaegertracing/jaeger/model"
)

func TestCodecMarshallAndUnmarshall_jaeger_type(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you sure tests are being executed in this proto-gen package? I thought we were excluding them (you have a fmt issue above so pretty sure linter is not running here). I think it's better not to mix generated code with manual code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To what package should we move this then? I can think of model only.

I think it's better not to mix generated code with manual code.

We already do mix packages e.g. model package.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the model we do it out of necessity, since gen-ed code doubles as domain model and the custom types ser/deset methods need to be there. But we usually don't write manual code in ***-gen packages.

You can create a new package like pkg/gogocodec

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best would be get rid of this, I cannot find custom codec in OTELcol, so perhaps it's doable to do it without it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The custom codec is needed only if a custom type (e.g. TaceID) is used directly in the request (probably also response) object - https://github.com/jaegertracing/jaeger-idl/blob/master/proto/api_v2/query.proto#L38 via https://github.com/jaegertracing/jaeger-idl/blob/master/proto/api_v2/query.proto#L128. If the TraceID` was wrapped into another message the serialization would work without the custom codec.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yurishkuro I have moved the codec to ./pkg/gogocodec package and imported it in query grpc handler and grpc plugin code.

Signed-off-by: Pavol Loffay <[email protected]>
Signed-off-by: Pavol Loffay <[email protected]>
@pavolloffay
Copy link
Member Author

Benchmark results look good to me. See the results below. The benchmark code is in this PR in the model package.

This PR:

GOMAXPROCS=1 go test -bench=. -test.benchtime=10s -benchmem -cpuprofile profile_cpu.out ./model                                                                                             
goos: linux
goarch: amd64
pkg: github.com/jaegertracing/jaeger/model
cpu: Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
BenchmarkKeyValueIsLessAndEquals 	313754542	        38.84 ns/op	       0 B/op	       0 allocs/op
BenchmarkKeyValuesSort           	83939259	       154.1 ns/op	      24 B/op	       1 allocs/op
BenchmarkKeyValuesWrapping       	1000000000	         0.2424 ns/op	       0 B/op	       0 allocs/op
BenchmarkSpanHash                	  552618	     21807 ns/op	    2695 B/op	     112 allocs/op
BenchmarkBatchSerialization/marshal         	15824212	       749.9 ns/op	     480 B/op	       7 allocs/op
BenchmarkBatchSerialization/unmarshal       	 7336722	      1737 ns/op	    1592 B/op	      25 allocs/op
PASS
ok  	github.com/jaegertracing/jaeger/model	68.924s

Master with github.com/gogo/protobuf/proto

GOMAXPROCS=1 go test -bench=. -test.benchtime=10s -benchmem -cpuprofile profile_cpu.out ./model                                                                                               
go: downloading github.com/golang/protobuf v1.3.5
goos: linux
goarch: amd64
pkg: github.com/jaegertracing/jaeger/model
cpu: Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
BenchmarkKeyValueIsLessAndEquals 	306750854	        39.29 ns/op	       0 B/op	       0 allocs/op
BenchmarkKeyValuesSort           	84167293	       151.4 ns/op	      24 B/op	       1 allocs/op
BenchmarkKeyValuesWrapping       	1000000000	         0.2390 ns/op	       0 B/op	       0 allocs/op
BenchmarkSpanHash                	  544084	     21888 ns/op	    2695 B/op	     112 allocs/op
BenchmarkBatchSerialization/marshal         	11489486	      1047 ns/op	     624 B/op	      10 allocs/op
BenchmarkBatchSerialization/unmarshal       	 7310154	      1633 ns/op	    1592 B/op	      25 allocs/op
PASS
ok  	github.com/jaegertracing/jaeger/model	68.099s

Master with ithub.com/golang/protobuf/proto

GOMAXPROCS=1 go test -bench=. -test.benchtime=10s -benchmem -cpuprofile profile_cpu.out ./model                                                                                                 
goos: linux
goarch: amd64
pkg: github.com/jaegertracing/jaeger/model
cpu: Intel(R) Core(TM) i7-9850H CPU @ 2.60GHz
BenchmarkKeyValueIsLessAndEquals 	306549897	        42.74 ns/op	       0 B/op	       0 allocs/op
BenchmarkKeyValuesSort           	77749569	       158.2 ns/op	      24 B/op	       1 allocs/op
BenchmarkKeyValuesWrapping       	1000000000	         0.2391 ns/op	       0 B/op	       0 allocs/op
BenchmarkSpanHash                	  553023	     21951 ns/op	    2695 B/op	     112 allocs/op
BenchmarkBatchSerialization/marshal         	11297779	      1064 ns/op	     624 B/op	      10 allocs/op
BenchmarkBatchSerialization/unmarshal       	 7264723	      1635 ns/op	    1592 B/op	      25 allocs/op
PASS
ok  	github.com/jaegertracing/jaeger/model	68.930s

@jpkrohling
Copy link
Contributor

Do I read it right that golang/protobuf and gogo/protobuf are on the same ballpark? If this benchmark is correct, is it even worth using gogo at all in our case?

Signed-off-by: Pavol Loffay <[email protected]>
@pavolloffay
Copy link
Member Author

Do I read it right that golang/protobuf and gogo/protobuf are on the same ballpark? If this benchmark is correct, is it even worth using gogo at all in our case?

We do not use gogo only for perf but also for using custom types (e.g. TraceID) and minimize allocations by not using nullable fields - this is not reflected in serialization benchmark. Also even when using golang/proto serialization the gogo generated code is most likely used. To properly compare gogo and stdlib the benchmark would have to generate model twice. For purpose of this PR ignore the golang/protobuf result.

Signed-off-by: Pavol Loffay <[email protected]>
@yurishkuro yurishkuro merged commit a2b2e4b into jaegertracing:master Jun 8, 2021
@@ -44,6 +44,8 @@ func (s *GRPCStorageIntegrationTestSuite) initialize() error {
err := command.ParseFlags([]string{
"--grpc-storage-plugin.binary",
s.pluginBinaryPath,
"--grpc-storage-plugin.log-level",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I added this when I was trying to determine why the plugin wasn't working. It's not necessary but I don't think it hurts anything either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade google.golang.org/grpc to 1.35.0 grpc: Server.Serve failed to create ServerTransport
5 participants