mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-11 01:20:07 -04:00
The Discovery struct held *compute.Service and *compute.InstancesService as fields and is boxed into the discovery.Discoverer interface. Once reflection is reachable in the program (it always is, via the YAML/config machinery), the Go linker conservatively retains every exported method of any concrete type reachable through an interface, including via struct fields. *compute.Service exposes ~150 sub-services and their operations, so all of them — 994 list/get operations and their serializers — were retained even though discovery only calls Instances.List. Wrap the single used operation in a closure over the concrete *compute.Service so the service lives only in closure context, which reflection cannot traverse. Returning a *compute.InstancesListCall would not help, since that type has an s *Service back-reference that re-propagates the marker, so the closure encapsulates the whole List/Filter/Pages chain and only exposes the *compute.InstanceList data type discovery already uses. compute/v1 footprint drops from ~4.9 MB to ~33 KB, and the prometheus and promtool binaries each shrink by ~13.5 MB. No functional or API change. Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| gce.go | ||
| metrics.go | ||