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
Improve client interceptors chaining #4568
Improve client interceptors chaining #4568
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much for doing this! One small nit, and can you please add benchmarking/the results of the benchmarking similar to #4524?
clientconn.go
Outdated
} | ||
return func(ctx context.Context, method string, req, reply interface{}, cc *ClientConn, opts ...CallOption) error { | ||
return interceptors[curr+1](ctx, method, req, reply, cc, getChainUnaryInvoker(interceptors, curr+1, finalInvoker), opts...) | ||
func chainManyUnaryClientInterceptors(interceptors []UnaryClientInterceptor) UnaryClientInterceptor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Drop "Many" from these function names. GoLang style leans toward Brevity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to come up with a right name since all function names like chain(Client|Server)(Unary|Stream)Interceptors
are already in use and chain(Unary|Stream)Interceptors
belonged to the server side, so to avoid confusion I simply inlined multi-interceptor chaining in all related functions and replaced else if
branches with switch case
s.
8e72326
to
c6c6f23
Compare
Can you please provide some benchmarks for this change for the Client Side interceptors? |
c6c6f23
to
b5c31a2
Compare
Added benchmaks and here's the result:
|
Hey, the benchmarks show a positive increase. Sorry, but the team can't take the PR with all the positive increases. The Server Side one was fantastic though :). |
Continuation of #4524.
RELEASE NOTES:
client: improve performance when multiple interceptors are used