You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a benchmark demonstrating lock contention when Marshaling/Unmarshaling maps.
This benchmark is derived from a Google service which experienced poor performance when handling protos with maps.
The current implementation of map decoding uses reflection. In particular reflect.New, reflect.NewAt, and reflect.(*Value).Addr all call reflect.(*rvalue).ptrTo.
reflect.(*rvalue).ptrTo uses a cache protected by a mutex. Grabbing this lock is what causes the problem.
reflect.(*rvalue).ptrTo also implements a fast path (which avoids critical sections) for certain types known to the compiler. Hopefully we can extend the compiler to generate descriptors for more types (https://golang.org/issue/17931) so that we can hit the fast path for all types needed for proto decoding.
PiperOrigin-RevId: 139337589
0 commit comments