Skip to content

otelgrpc: performance issue about otlpreceiver invoke proto.Size slow path #3165

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

Closed
hanjm opened this issue Jan 17, 2023 · 2 comments · Fixed by #3168
Closed

otelgrpc: performance issue about otlpreceiver invoke proto.Size slow path #3165

hanjm opened this issue Jan 17, 2023 · 2 comments · Fixed by #3168
Milestone

Comments

@hanjm
Copy link
Member

hanjm commented Jan 17, 2023

The opentelemetry collector otlpreceiver consume lots of cpu for proto.Size, marshal to buffer, get buffer size.

related open-telemetry/opentelemetry-collector#6947

I think it shoud try get size from asserting interface Size() int, then try to use proto.Size

@bogdandrutu
Copy link
Member

bogdandrutu commented Jan 17, 2023

A possible better option is to actually implement stats.Handler (which was designed for this) instead of unary/streaming interceptors. The stats handlers have all the lengths pre-calculated and available.

See OpenCensus https://github.com/census-instrumentation/opencensus-go/blob/v0.24.0/plugin/ocgrpc/server.go#LL32C4-L32C4

Another advantage is that it works with any encoding not only protobuf and gRPC supports other encodings.

@Aneurysm9
Copy link
Member

I have created #3168 to remove the attribute for the time being. I agree that the stats.Handler interface looks like it is the correct way to go in the longer term, but I do not know when such an implementation can be created.

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 a pull request may close this issue.

4 participants