Comment #5 on issue 374 by Add method in ByteString to avoid big buffer copy.

We've used Benoit's approach in core Apache code. Our final version is:

package;  // This is a lie.

public final class ZeroCopyLiteralByteString extends LiteralByteString {
  private ZeroCopyLiteralByteString() { super(null);}

  public static ByteString wrap(final byte[] array) {
    return new LiteralByteString(array);
    // return ByteString.copyFrom(array);

public static ByteString wrap(final byte[] array, int offset, int length) {
    return new BoundedByteString(array, offset, length);
    // return ByteString.copyFrom(array, offset, length);

We we change this to use the official ByteString.copyFrom, using the standard YCSB perf tool, we see a degradation of performance of 22%. That is, just using the commented lines of code above cost 22% of messages managed per second (from 167000 to 130000).

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