Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
xdr: optimize encoding of ByteBuffer
Motivation: When a ByteBuffer is encoded into XdrStream then a implicit copy of underlaying data is performed. By wrapping ByteBuffer with and building a composite buffer the additional copy can be avoid. Modification: Add Xdr#xdrEncodeShallowByteBuffer that creates a composite buffer to avoid extra copy. Result: Encoding of a ByteBuffer is an O(1) operation, if possible (original buffer is not modified). Buffer size XdrBenchmark.encodeByteBufferShallow 1024 thrpt 5 9402670.599 ± 26808.413 ops/s XdrBenchmark.encodeByteBufferShallow 8192 thrpt 5 9102908.516 ± 64365.443 ops/s XdrBenchmark.encodeByteBufferShallow 262144 thrpt 5 9182060.856 ± 83327.650 ops/s XdrBenchmark.encodeByteBufferShallow 1048576 thrpt 5 9052320.542 ± 23289.002 ops/s XdrBenchmark.encodeByteBuffer 1024 thrpt 5 28773875.725 ± 250222.745 ops/s XdrBenchmark.encodeByteBuffer 8192 thrpt 5 6439241.956 ± 24534.514 ops/s XdrBenchmark.encodeByteBuffer 262144 thrpt 5 88237.372 ± 704.050 ops/s XdrBenchmark.encodeByteBuffer 1048576 thrpt 5 21276.243 ± 116.393 ops/s Acked-by: Albert Rossi Target: master
- Loading branch information