RFR: 8361209: (bf) Use CharSequence::getChars for StringCharBuffer bulk get methods

Brian Burkhalter bpb at openjdk.org
Thu Jul 10 20:34:53 UTC 2025


On Thu, 10 Jul 2025 20:27:52 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> For `CharBuffer`s created from a `CharSequence`, use `CharSequence.getChars` to perform bulk gets instead of successively copying single characters.

The throughput of the methods affected is increased by approximately 4.8X. Sample results:

**Master branch**

Result "org.openjdk.bench.java.nio.StringCharBufferBulkGet.absoluteBulkGet":
  531557.108 ±(99.9%) 6055.644 ops/s [Average]
  (min, avg, max) = (529972.576, 531557.108, 533558.521), stdev = 1572.632
  CI (99.9%): [525501.464, 537612.752] (assumes normal distribution)

**This branch**

Result "org.openjdk.bench.java.nio.StringCharBufferBulkGet.absoluteBulkGet":
  2547276.973 ±(99.9%) 6955.224 ops/s [Average]
  (min, avg, max) = (2544172.461, 2547276.973, 2548847.355), stdev = 1806.250
CI (99.9%): [2540321.749, 2554232.197] (assumes normal distribution)

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

PR Comment: https://git.openjdk.org/jdk/pull/26251#issuecomment-3058968191


More information about the nio-dev mailing list