@@ -156,9 +156,37 @@ commit a1008887b9ab4553a79ce82cf6d3db324c344977
156156- The old version set ` ServiceSearcher ` on rpcinfo; the new version moves it to context to optimize Get/Set performance.
157157``` diff
158158commit a1008887b9ab4553a79ce82cf6d3db324c344977
159- // SetOrCheckMethodName is used to set method name to invocation.
159+ Author: Jayant <xiezhengyao@bytedance.com>
160+ Date: Wed Sep 17 15:52:37 2025 +0800
161+
162+ perf: optimize cost of setting service searcher and update min go version to 1.20 (#1855)
163+
164+ diff --git a/pkg/remote/codec/util.go b/pkg/remote/codec/util.go
165+ index d8e293d4..c257d8b8 100644
166+ --- a/pkg/remote/codec/util.go
167+ +++ b/pkg/remote/codec/util.go
168+ @@ -32,7 +32,7 @@ const (
169+ )
170+
171+ // SetOrCheckMethodName is used to set method name to invocation.
160172- func SetOrCheckMethodName(methodName string, message remote.Message) error {
161173+ func SetOrCheckMethodName(ctx context.Context, methodName string, message remote.Message) error {
174+ ri := message.RPCInfo()
175+ ink := ri.Invocation()
176+ callMethodName := ink.MethodName()
177+ @@ -52,10 +52,7 @@ func SetOrCheckMethodName(methodName string, message remote.Message) error {
178+ var svcInfo *serviceinfo.ServiceInfo
179+ var methodInfo serviceinfo.MethodInfo
180+ // for ping pong server, svc info is nil until the request decoded
181+ - svcSearcher := remote.GetServiceSearcher(ri)
182+ - if svcSearcher == nil {
183+ - return errors.New("RPCInfo doesn't contains a service searcher")
184+ - }
185+ + svcSearcher := remote.GetServiceSearcher(ctx)
186+ svcInfo = svcSearcher.SearchService(ink.ServiceName(), methodName, false, ri.Config().PayloadCodec())
187+ if svcInfo == nil {
188+ return remote.NewTransErrorWithMsg(remote.UnknownService, fmt.Sprintf("unknown service %s, method %s", ink.ServiceName(), methodName))
189+
162190```
163191- This simultaneously affects the definition of ` codec.SetOrCheckMethodName ` , adding ` context.Context ` as a parameter.
164192
0 commit comments