proto: specialize map<string, string> for performance
Author: jmillikin-stripeCreated Jan 8, 2019Updated Aug 2, 2026
Labelsperformance
Background: https://github.com/golang/protobuf/issues/624
Serialization of map fields currently hits a slow, reflection-based path. This is understandable for the general case (nested messages are hard), but there are some special cases where maps get used a lot and a fast path would be very valuable.
My specific use case is a map<string, string> used to represent arbitrary human-meaningful metadata in a distributed monitoring system (similar to Prometheus). Benchmarking shows that our tooling is spending a material amount of CPU time in the closures returned from proto.makeMapMarshaler.
Source: golang/protobuf