Skip to content

Commit

Permalink
Try to speed up protobuf marshalling / unmarshalling.
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurschreiber committed Apr 11, 2024
1 parent 9a39198 commit 4e18265
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions go/vt/topo/srv_vschema.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
"fmt"
"sync"

"google.golang.org/protobuf/proto"

"vitess.io/vitess/go/vt/log"
"vitess.io/vitess/go/vt/vterrors"

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
}
Expand All @@ -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
}
Expand All @@ -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
Expand Down

0 comments on commit 4e18265

Please sign in to comment.