-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
FlatBuffer zero copying not working as expected. [JAVA, Flatbuffers 1.11.0, OSX] #6023
Comments
The promised "zero copy" with FlatBuffers & gRPC refers to C++, not Java (see e.g. https://grpc.io/blog/grpc-flatbuffers/). Not sure how you would achieve zero copy in Java. Also not sure what |
Apologies for the typo, i meant createString. I also observed a similar slowdown when using |
When you are serializing, you are basically copying all the other objects you want to serialize into Flatbuffer internal's AFAIK that happens on all managed languages, not only java. Having said that, in theory, it should be possible to mitigate the copying. FlatbufferBuilder could support some sort of internal linked-list like structure where you could simply append additional One reference implementation is netty's CompositeBuffer. That is also why I added a more flexible buffer interface on FlexBuffers, so we can experiment with this optimizations in the future. Tl;Dr: It does copy. Does not create intermediate objects. Might allocate if the |
This issue is stale because it has been open 6 months with no activity. Please comment or this will be closed in 14 days. |
Use case:
I am trying to achieve zero intermediate copying semantics by utilizing flatbuffers in GRPC streaming.
To benchmark correctly, I developed a small client-server program that repeatedly transfers 1MB data (over 100000 times) utilizing flatbuffers over GRPC.
Issue:
What I observed through CPU profiling the client is that a significant percentage of time is spent when creating the message in the application layer; Specifically in the createString() because that creates a copy of the data.
The expectation was that no intermediate copying of data will happen. Am I taking the wrong approach to create a message? Is there a way to use the FlatBufferBuilder’s internal ByteBuffer to write application data directly, or have the internal ByteBuffer refer to an application buffer slice?
Code:
Client
Flatbuffers schema
The text was updated successfully, but these errors were encountered: