Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does flatbuffers serialize empty fields in output as well if it's not specified? #6520

Closed
hiqsociety opened this issue Mar 17, 2021 · 2 comments

Comments

@hiqsociety
Copy link

Wondering if total size generated can be lowered if it is able to ignore empty fields and not serialize the "header" key value.

If not, possible to implement in the next version of flatbuffers?

@CasperN
Copy link
Collaborator

CasperN commented Mar 17, 2021

Does flatbuffers serialize empty fields in output as well if it's not specified?

No, if a field is not set (or if there's a default and its set to the default) then we do not serialize the field.
There is a 2byte overhead in the vtable but that's amortizable by vtable sharing.

If not, possible to implement in the next version of flatbuffers?

See #5875 for ideas on further evolution of Flatbuffers.

@CasperN
Copy link
Collaborator

CasperN commented Mar 17, 2021

...not serialize the "header" key value.

Actually you might be referring to the 2byte vtable overhead here. In which case, I guess "yes, a little" is a better answer to the title question. We'd have to change how vtables work to get rid of the overhead: We index into the vtable with the field-id to find the offset to the field's value and if we choose not to write anything when the field is not present, we'd have to do something more complex than indexing and probably would trade away some speed.

@CasperN CasperN closed this as completed Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants