You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Protocol Buffers
Greetings , in our Java application we use the protobuf object
model quite a bit. While profiling, I have noticed that simply getting
an enum value from an object is quite slow. It appears to be caused by
the fact that the object stores internally an int which must be
converted to a java enum on ever call to the getter. If the object just
stored the enum value directly, this would not be necessary. The
required translation between int<->enum could just be done once on
(de)serialization. Wondering if this would qualify for a performance
request.
Thanks
Jerry Berg
unread,
Jan 27, 2023, 12:28:32 PM1/27/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Protocol Buffers
Hi Andrei,
This doesn't work for proto3 where we need to support "open enums" so that enum values added to an enum definition but not yet compiled into the receiver can still be stored and accessed as a raw int. This can't be done with Java's Enums which are "closed enums". Our long term plan is that proto enums will default to open as in proto3, so we are unlikely to change this behavior. If enum access is unacceptably slow, consider switching to int32 values -- it is a wire compatible change though certainly not quite as convenient or self-documenting.