Comment #5 on issue 374 by [email protected]: Add method in ByteString to avoid big buffer copy.
http://code.google.com/p/protobuf/issues/detail?id=374

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

package com.google.protobuf;  // 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:
https://code.google.com/hosting/settings

--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to