buf icon indicating copy to clipboard operation
buf copied to clipboard

Remove unused options on field descriptors with excluded types

Open emcfarlane opened this issue 9 months ago • 0 comments

Feature

Excluding types removes the types and types that depend on it (fields, methods). Options aren't removed from the file descriptor as they can safely be ignored as unrecognized bytes when the extension is removed.

However, this can bloat the generated code for languages that include the full file descriptor. Languages like ruby are particular sensitive as the bytes aren't compressed. For example, using protovalidate/example removing protovalidate types with --exclude-type=buf.validate will produce generated code without dependency on buf.validate but the protovalidate options account for 15% of the generated code size. Protobuf-es v2 (protoc-gen-es) is also affected but less at 5%.

emcfarlane avatar Apr 01 '25 16:04 emcfarlane