Comment #8 on issue 429 by Support ByteBuffer in CodedInputStream and CodedOutputStream to avoid redundant copies for direct ByteBuffer.

We tried to implement a CodedInputStream which reads directly from a direct ByteBuffer but it turns out to make the parsing performance worse (i.e., copy the whole content to byte[] then parsing from byte[] is better than parsing from ByteBuffer directly). The fact is, ByteBuffer.get() is several times slower then byte[i] and as in protobuf we do a lot of varint decoding (which reads byte by byte), making a copy to byte[] gives us the better performance in almost all cases.

As a result we are not pursing avoiding this seemingly "redundant copy" in CodedInputStream. If you have a particular proto which only contains several large bytes field, wrapping the ByteBuffer in an InputStream might work better for you. But for general use, the current implementation should be the right approach.

You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:

You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to