RFR: 8305811: (bf) Improve heap buffer performance of CharBuffer::append(CharSequence)

Brian Burkhalter bpb at openjdk.org
Thu Apr 13 00:39:43 UTC 2023


On Tue, 11 Apr 2023 00:11:50 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Use the `getChars` method of `String`, `StringBuffer`, and `StringBuilder` to load the chars directly into the array of the heap buffer.

Redone benchmarks of commit 67025b90982075d2486e2c4e72bccbcefb61cde2 and the baseline yield these results:


**Before**

Benchmark                                 Mode  Cnt        Score       Error  Units
CharBufferAppend.appendDirectToDirect    thrpt   10   138125.663 ±  1231.206  ops/s
CharBufferAppend.appendHeapToDirect      thrpt   10   163259.065 ±   765.823  ops/s
CharBufferAppend.appendHeapToHeap        thrpt   10  1034814.203 ±  6981.516  ops/s
CharBufferAppend.appendString            thrpt   10  4741539.674 ± 67549.777  ops/s
CharBufferAppend.appendStringBuffer      thrpt   10  4642430.191 ± 49655.167  ops/s
CharBufferAppend.appendStringBuilder     thrpt   10  1226675.563 ± 31026.688  ops/s
CharBufferAppend.appendSubString         thrpt   10  2759689.491 ± 11241.499  ops/s
CharBufferAppend.appendSubStringBuffer   thrpt   10  2719970.162 ± 11851.111  ops/s
CharBufferAppend.appendSubStringBuilder  thrpt   10  2839501.735 ± 13956.792  ops/s


**After**

Benchmark                                 Mode  Cnt         Score        Error  Units
CharBufferAppend.appendDirectToDirect    thrpt   10   4892275.689 ± 181835.150  ops/s
CharBufferAppend.appendHeapToDirect      thrpt   10   2667659.324 ±  43501.152  ops/s
CharBufferAppend.appendHeapToHeap        thrpt   10   3858407.495 ±  94133.585  ops/s
CharBufferAppend.appendString            thrpt   10   4628513.408 ±  52763.037  ops/s
CharBufferAppend.appendStringBuffer      thrpt   10   6592570.654 ± 128713.879  ops/s
CharBufferAppend.appendStringBuilder     thrpt   10   4059924.596 ±  76503.763  ops/s
CharBufferAppend.appendSubString         thrpt   10   2775968.589 ±  11224.194  ops/s
CharBufferAppend.appendSubStringBuffer   thrpt   10   2760357.674 ±  13907.420  ops/s
CharBufferAppend.appendSubStringBuilder  thrpt   10  13537629.653 ± 153876.164  ops/s

-------------

PR Comment: https://git.openjdk.org/jdk/pull/13415#issuecomment-1506144775


More information about the nio-dev mailing list