In my company we were using flatbuffers for few months and after we realized we would need grpc sooner than we thought, we had to switch to protocol buffer.
With these months of use, we faced some difficulties with flatbuffers and I wanted to share my questions and insights with you.
From a high level aspect & ease of use:
About versionning:
About performance:
Thank you very much,
Thanks for your extensive feedback!
You had to switch to Protobuf because we don't have GRPC bindings for all the languages that you use?
Comments on your bullets in the same order:
CreateVector which adds all elements in one go. If doing it by element is not document clearly, this is an oversight, please file an issue.Versioning:
Performance:
Made some documentation fixes based on the above here: https://github.com/google/flatbuffers/commit/4b27c92910ebe57c1d21932df2a85c142516c7b4
Other issues have been noted (Object API for more languages, Java performance, removal of deprecated fields) but will take longer to materialize :)
Thank you for your detailed answer ! Yes, we needed GRPC support for Python and C++ (which I saw has been reworked few weeks ago).
Here are my answers/new questions:
High level :
Versionning:
Performance:
Thank you for taking notes of my insights, hope this get materialized soon :)
High level:
Versioning:
deprecated_field where right now you must write some_name:some_type (deprecated). The schema compiler needs to know there used to be a field there.Performance:
long will always take 8 bytes, whereas Protobuf uses varints. Protobuf needs one or two bytes preceding each value for type/id, whereas we have vtables (which may be amortized or not), alignment etc. So it strongly depends on your schema and your actual data how efficient that will be.Thanks, everything is clear for me now.
Hope this issue gave you some areas of improvement ! I let you close it :)
Hello, sorry for jumping in this conversation, but I am not clear why we need the deprecated field. I mean if we have for example: table { c:int (id: 2); b:int (id: 1); } where a field has been removed entirely, should not we generate a vtable with entriies 0, 1 and 2 and entry 0 is always 0 offset (always empty). Is not this what does "deprecated" property ?
Of course it's entirely possible I missed something.
Thanks a lot
@zejal yes, when using ids, we could simply leave out fields entirely.
However, we still need a way to do that when not using ids.
Also, even when using ids, because it is quite important that ids are assigned sequentially for performance, it is nice to be able to check that with an error. For example, if you add a new field and skip an id, there's no way to tell the difference between that being an error or an intentional deprecated field.
I see thanks. Would it be safe then to simply put some "placeholder" with arbitrary type ? ie go from
table { a:int; b:int; c:int } to: table { deprecated0 : empty (deprecated); b:int; c:int } where "empty" is some type (an empty table for example). The question comes from the fact we might generate FlatBuffers schémas from our own idl format and we'd like to be able to remove fields complelely, at the cost of having explicit ids. So we'd lose name and type.
Yes, a placeholder would be fine. In fact that was one of the suggestions above: the ability to have placeholders without a name or a type. Using some kind of type specifically for this purpose sounds like an ok alternative.
@maingoh You asked for a DebugString that works without loading a schema, it just arrived here: https://github.com/google/flatbuffers/commit/72a99abfb7db64dc49720b28b41f382b5ec7cde0
Wow, I didn't expect it to arrive as fast. Thanks for your great work! Also does it handle serialization to json?
@maingoh : this new code converts a FlatBuffer to a string which as close as possible to JSON (though at the moment, FlatBuffers' more permissive JSON, i.e. there are no string quotes around field names).
There is no parsing of JSON to FlatBuffers using this mini-reflection yet, which would be possible, but a fair bit more complicated. For the moment, best to use the existing Parser for that purpose.
Alright I was just asking for an export to json as in some cases we need to give our user an human readable result (from a buffer) which would be easier to parse for them if it was strict json.
Just giving you my use cases, don't feel forced to implement those features only because of me ;)
If I remember correctly there is already a facility to convert back and forth from JSON and FlatBuffer binary format ? Certainly from JSON to FB (use it routinely). The only thing that JSON output does not handle as far as I know is the eventual multiple references to same table in the structure.
Best.
De : Hugo Maingonnatnotifications@github.com
Envoyé le :jeudi 28 septembre 2017 22:33
À : google/flatbuffersflatbuffers@noreply.github.com
Cc : zejaljosephcanedo@hotmail.com; Mentionmention@noreply.github.com
Objet :Re: [google/flatbuffers] Existential questions and insights (#4385)
Alright I was just asking for an export to json as in some cases we need to give our user an human readable result (from a buffer) which would be easier to parse for them if it was strict json.
Just giving you my use cases, don't feel forced to implement those features only because of me ;)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/google/flatbuffers/issues/4385#issuecomment-332955547, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AZSv1mlnSMjBgeYYMJJFkiwI-8yVx48mks5snAJ6gaJpZM4OZa2h.
@zejal yes, there's been bi-directional FlatBuffers <-> JSON right from the start. But it involves parsing a schema at run-time.
This new functionality does FlatBuffers -> JSON without loading or parsing a schema.
Just wanted to chime in and say we choose protobuf for a project that wasn't performance sensitive because --gen-object-api isn't supported for java/python (ie. https://github.com/google/flatbuffers/issues/4769).
In general, I think having the simpler API would make flatbuffers very close to being strictly better than protobuf.
@mfarrugi I agree we should have it for every language, it just hasn't happened yet. Contributions welcome.
This issue has been automatically marked as stale because it has not had activity for 1 year. It will be automatically closed if no further activity occurs. To keep it open, simply post a new comment. Maintainers will re-open on new activity. Thank you for your contributions.
Most people would use CreateVector which adds all elements in one go. If doing it by element is not document clearly, this is an oversight, please file an issue.
@aardappel Hey there, does CreateVector add them in reverse order?
Most helpful comment
Thanks for your extensive feedback!
You had to switch to Protobuf because we don't have GRPC bindings for all the languages that you use?
Comments on your bullets in the same order:
CreateVectorwhich adds all elements in one go. If doing it by element is not document clearly, this is an oversight, please file an issue.Versioning:
Performance: