code: public int getSerializedSize() {
      int size = 0;
      for (int i = 0; i < fields.getNumArrayEntries(); i++) {
        final Map.Entry<FieldDescriptorType, Object> entry =
            fields.getArrayEntryAt(i);
        size += computeFieldSize(entry.getKey(), entry.getValue());
      }
      for (final Map.Entry<FieldDescriptorType, Object> entry :
           fields.getOverflowEntries()) {
        size += computeFieldSize(entry.getKey(), entry.getValue());
      }
      return size;
    }
docs: See {@link Message#getSerializedSize()}.  It's up to the caller to cache
  the resulting size if desired.