Skip to content

roachpb: Protobuf encoding does not omit empty messages #85312

@erikgrinaker

Description

@erikgrinaker

As seen over in #85138 (comment), it appears that gogoproto is encoding embedded messages even though they are empty. In other words, consider this message:

message Foo {
  Timestamp timestamp = 1; 
}

message Timestamp {
  int64 wall_time = 1;
  int32 logical = 2;
  bool synthetic = 3;
}

Even though empty Protobuf fields can be omitted, gogoproto will encode an empty Foo into 2 bytes: 0x0a 0x00, which essentially says field 1 of wire type delimited with length 0 (see encoding spec).

The encoding should be able to omit this field entirely, which might net us some minor savings throughout the codebase (e.g. for every unset timestamp field).

Jira issue: CRDB-18178

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-kvAnything in KV that doesn't belong in a more specific category.C-performancePerf of queries or internals. Solution not expected to change functional behavior.T-kvKV Team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions