Skip to content

Instantly share code, notes, and snippets.

@yifan-gu
Created December 26, 2013 05:57
Show Gist options
  • Save yifan-gu/8130307 to your computer and use it in GitHub Desktop.
Save yifan-gu/8130307 to your computer and use it in GitHub Desktop.
repeated vs seperate field
2 * int64 and 1 * int32
BenchmarkPreAcceptProtoMarshal 5000000 480 ns/op 220.38 MB/s
5 * int32
BenchmarkPreAcceptProtoMarshal 5000000 584 ns/op 188.23 MB/s
repeated(slice) type
BenchmarkPreAcceptProtoMarshal 1000000 1282 ns/op 266.76 MB/s
@yifan-gu
Copy link
Author

message PreAccept {
option (gogoproto.face) = true;
option (gogoproto.goproto_getters) = false;

/*
  LeaderId int32
  Replica int32
  Instance int32
  Ballot int32
  Command []byte
  Seq int32
  Deps [5]int32
*/
required int32 LeaderId = 1 [(gogoproto.nullable) = false];
optional int32 Replica = 2 [(gogoproto.nullable) = false];
optional int32 Instance = 3 [(gogoproto.nullable) = false];
optional int32 Ballot = 4 [(gogoproto.nullable) = false];
optional bytes Command = 5 [(gogoproto.nullable) = false];
optional int32 Seq = 6 [(gogoproto.nullable) = false];
repeated int32 Deps = 7 [(gogoproto.nullable) = false];
/*optional int32 Deps1 = 7 [(gogoproto.nullable) = false];
optional int32 Deps2 = 8 [(gogoproto.nullable) = false];
optional int32 Deps3 = 9 [(gogoproto.nullable) = false];
optional int32 Deps4 = 10 [(gogoproto.nullable) = false];
optional int32 Deps5 = 11 [(gogoproto.nullable) = false];*/

/*optional int64 Deps1 = 7 [(gogoproto.nullable) = false];
  optional int64 Deps2 = 8 [(gogoproto.nullable) = false];
  optional int32 Deps3 = 9 [(gogoproto.nullable) = false];*/

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment