replace context.WithValue
string key to typed struct{}
key
#11634
Labels
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
type/performance
Current TiDB many places uses a string as the context key which leads to allocations.
for example:
tidb/store/tikv/coprocessor.go
Line 52 in eae30eb
tidb/session/session.go
Line 505 in 7f3bff8
https://golang.org/pkg/context/#WithValue
https://www.dropbox.com/s/9u74uvpq8vowwdo/Screenshot%202019-07-30%2012.39.20.png?dl=0
instead, we'd better using
type xKey struct{}
just like opentracing does https://github.com/opentracing/opentracing-go/blob/master/gocontext.go#L12 to reduce allocThe text was updated successfully, but these errors were encountered: