-
Notifications
You must be signed in to change notification settings - Fork 86
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
Efficient array serialization #38
Comments
Cap'n Proto lists are just dynamically-sized arrays. Accessing their elements is fast, though it does need to go through a list pointer. I recommend trying them and measuring whether the performance is good enough for you. If you want to avoid the list-pointer indirection, then you probably are interested in inline lists, a proposed future feature of Cap'n Proto. Although inline lists don't exist yet in Cap'n Proto, you can fake them by manually creating fields for each element of the list, like this: struct Foo {
array0 @0 :Int16;
array1 @1 :Int16;
array2 @2 :Int16;
array3 @3 :Int16;
} Also, you may be interested in reading this discussion from last year. |
Thanks for your reply! I was first busy on giving msgpack a try. But now I would really love to try capn proto out. Unfortunately I don't get BTW, |
capnpc-java depends on capnproto, but is not included with it. Once you've installed capnproto you'll need to build capnpc-java from source by running |
Ok, thanks for that. That was easier than i thought. I was kind of (sorry for the questions, but I just don't get it. Maven repository would 2015-08-24 14:29 GMT+02:00 David Renshaw [email protected]:
|
Unfortunately, I know very little about Java packaging and build systems. I know that |
Oh yeah. That is really nice. Maybe you could provide this information on Now, another one question: if I want to send that message by zeromq, I But I'm not sure if there is such a method for java?! 2015-08-24 15:57 GMT+02:00 David Renshaw [email protected]:
|
I got an array representation using write(BufferedOutputStream, MessageBuilder) and retrieving the ButeArray from it and turning it into byte[]. But for zeromq you need to subscribe to certain filters. Meaning like first byte of the message?! Can you help me retrieve this information? Cheers On Mon, Aug 24, 2015 at 6:01 PM, Alexey Egorov
|
Ok, I've done it and got the whole stuff running. 2015-08-24 18:46 GMT+02:00 Alexey Egorov [email protected]:
|
Cool, I'm glad you've got it working. I agree that it could be good to use your code as an example, perhaps in the documentation (the gh-pages branch) or in the examples/ directory. Did you manage to make any measurements with your comparison to msgpack and protobuf? I'd be curious to hear about how well capnproto-java fared. |
The comparisons seemed well concerning CPU time as I sent the messages without serialization by getting segments and sending them as ByteBuffers. So while we were able to get around 1500 messages/second serialized and put into ZeroMQ with protocol buffers, we achieved around 2300 messages/second with Cap'n Proto. Our message contains some telescope image data, so they are pretty big. |
Note that |
ArrayOutputStream is a very good hint! :) I added another class that just can construct a bigger buffer in case the original one is too small, but in general it is fine now. netty's ChannelBuffer could be a good try to test the speed and timing... But for now I'm good with it. 👍 |
Hello,
we've currently considering protocol buffers for serializing the data. But they seem to be slow while deserializing using java and don't have support for int16 (or int8) as Cap'n Proto does. Cap'n Proto documentation says nothing about arrays, but only lists. As our data mostly consists of short-arrays and need a very fast access to them, lists are inappropriate for us.
Can you help us to learn whether Cap'n Proto does support array serialization in java?
Thanks in advance.
Alexey
The text was updated successfully, but these errors were encountered: