RFR: 8306374: (bf) Improve performance of DirectCharBuffer::append(CharSequence[,int,int])
Brian Burkhalter
bpb at openjdk.org
Wed Apr 19 00:36:05 UTC 2023
On Wed, 19 Apr 2023 00:29:14 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Use `getChars()` to copy characters to an intermediate local `char[]` array and then `putArray()` to copy the chars into the buffer itself.
Appending a sequence of 32768 characters gave the following results:
**Before**
Benchmark Mode Cnt Score Error Units
CharBufferAppend.appendStringBufferToDirect thrpt 10 42746.409 ± 436.898 ops/s
CharBufferAppend.appendStringBuilderToDirect thrpt 10 39007.579 ± 934.130 ops/s
CharBufferAppend.appendStringToDirect thrpt 10 47820.006 ± 1142.298 ops/s
CharBufferAppend.appendSubStringBufferToDirect thrpt 10 79981.671 ± 2248.619 ops/s
CharBufferAppend.appendSubStringBuilderToDirect thrpt 10 82032.943 ± 890.607 ops/s
CharBufferAppend.appendSubStringToDirect thrpt 10 80458.162 ± 1396.552 ops/s
**After**
Benchmark Mode Cnt Score Error Units
CharBufferAppend.appendStringBufferToDirect thrpt 10 41448.953 ± 1176.265 ops/s
CharBufferAppend.appendStringBuilderToDirect thrpt 10 317041.262 ± 4242.432 ops/s
CharBufferAppend.appendStringToDirect thrpt 10 47376.189 ± 479.143 ops/s
CharBufferAppend.appendSubStringBufferToDirect thrpt 10 551124.908 ± 4773.753 ops/s
CharBufferAppend.appendSubStringBuilderToDirect thrpt 10 616143.045 ± 9020.091 ops/s
CharBufferAppend.appendSubStringToDirect thrpt 10 605963.509 ± 6222.007 ops/s
Throughput is either effectively unchanged or increased by a factor of 6 to 8.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/13522#issuecomment-1513952917
More information about the nio-dev
mailing list