mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-02-04 12:39:49 +00:00
82c6b3ad29
Resolves golang/protobuf#1521 In the internal/impl package, a helper computes metadata used for serialization and deserialization of extension values. It features a package var of type sync.Map that is used as cache. This ostensibly was for performance, however it has never worked, because the code that updates the cache inserts entries into the wrong map. (These erroneous entries do not cause any issues because they are keys that never conflict with those used in valid queries.) Instead of a one-line fix to have this code update the correct cache, this change removes the cache altogether. The existence of the cache means that once a protoreflect.ExtensionType is used to serialize or deserialize a message, it can *never* be garbage collected. Workloads that are long-lived servers using dynamic messages and extensions based on user requests will exhibit unbounded growth in memory usage as the cache only gets larger and larger. Since the cache has never worked, any advantages it ostensibly conferred have not been missed. So this fixes the unbounded memory growth instead. Change-Id: I15957fd8521852f9f7f9f89db7ebfd7170d85202 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/560095 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Michael Stapelberg <stapelberg@google.com> Reviewed-by: Lasse Folger <lassefolger@google.com> Reviewed-by: Damien Neil <dneil@google.com>