From cdfbeff1ba9fda9a0aa30c9ae4453f2d7a1d5ef1 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Sat, 17 Jun 2017 09:05:14 -0400 Subject: [PATCH] Generate protobuf with stable ordered maps The default marshalers from gogo-protobuf do not order keys, which means successive serializations of the same data would result in same bytes. Kubernetes leverages stable serialization to avoid excessive writes to etcd when body content has not changed, which reduces the amount of watch traffic generated by successive callers. This will have a small memory impact on objects which have maps - allocating a new string array for each map key. All maps must be keys because we serialize those to JSON, so non-string types are not relevant. --- cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go | 1 + 1 file changed, 1 insertion(+) diff --git a/cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go b/cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go index ed826b9c3be..d29e3e4751d 100644 --- a/cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go +++ b/cmd/libs/go2idl/go-to-protobuf/protobuf/generator.go @@ -52,6 +52,7 @@ func (g *genProtoIDL) PackageVars(c *generator.Context) []string { } return []string{ "option (gogoproto.marshaler_all) = true;", + "option (gogoproto.stable_marshaler_all) = true;", "option (gogoproto.sizer_all) = true;", "option (gogoproto.goproto_stringer_all) = false;", "option (gogoproto.stringer_all) = true;",