From 4e182655561ec6ecf4f4e683a59976cc27e8486a Mon Sep 17 00:00:00 2001 From: Arthur Schreiber Date: Thu, 11 Apr 2024 20:59:58 +0000 Subject: [PATCH] Try to speed up protobuf marshalling / unmarshalling. --- go/vt/topo/srv_vschema.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/go/vt/topo/srv_vschema.go b/go/vt/topo/srv_vschema.go index 204b2696370..453e8c5f8d0 100644 --- a/go/vt/topo/srv_vschema.go +++ b/go/vt/topo/srv_vschema.go @@ -21,8 +21,6 @@ import ( "fmt" "sync" - "google.golang.org/protobuf/proto" - "vitess.io/vitess/go/vt/log" "vitess.io/vitess/go/vt/vterrors" @@ -54,7 +52,7 @@ func (ts *Server) WatchSrvVSchema(ctx context.Context, cell string) (*WatchSrvVS return nil, nil, err } value := &vschemapb.SrvVSchema{} - if err := proto.Unmarshal(current.Contents, value); err != nil { + if err := value.UnmarshalVT(current.Contents); err != nil { // Cancel the watch, drain channel. cancel() for range wdChannel { @@ -83,7 +81,7 @@ func (ts *Server) WatchSrvVSchema(ctx context.Context, cell string) (*WatchSrvVS } value := &vschemapb.SrvVSchema{} - if err := proto.Unmarshal(wd.Contents, value); err != nil { + if err := value.UnmarshalVT(wd.Contents); err != nil { cancel() for range wdChannel { } @@ -105,7 +103,7 @@ func (ts *Server) UpdateSrvVSchema(ctx context.Context, cell string, srvVSchema } nodePath := SrvVSchemaFile - data, err := proto.Marshal(srvVSchema) + data, err := srvVSchema.MarshalVT() if err != nil { return err } @@ -126,7 +124,7 @@ func (ts *Server) GetSrvVSchema(ctx context.Context, cell string) (*vschemapb.Sr return nil, err } srvVSchema := &vschemapb.SrvVSchema{} - if err := proto.Unmarshal(data, srvVSchema); err != nil { + if err := srvVSchema.UnmarshalVT(data); err != nil { return nil, vterrors.Wrapf(err, "SrvVSchema unmarshal failed: %v", data) } return srvVSchema, nil