RFR: 8282047: Enhance StringDecode/Encode microbenchmarks

Brent Christian bchristi at openjdk.java.net
Thu Feb 24 19:37:11 UTC 2022


On Thu, 17 Feb 2022 15:11:11 GMT, Claes Redestad <redestad at openjdk.org> wrote:

> Splitting out these micro changes from #7231
> 
> - Clean up and simplify setup and code
> - Add variants with different inputs with varying lengths and encoding weights, but also relevant mixes of each so that we both cover interesting corner cases but also verify that performance behave when there's a multitude of input shapes. Both simple and mixed variants are interesting diagnostic tools.
> - Drop all charsets from the default run configuration except UTF-8. Motivation: Defaults should give good coverage but try to keep runtimes at bay. Additionally if the charset tested can't encode the higher codepoints used in these micros the results might be misleading. If you for example test using ISO-8859-1 the UTF-16 bytes in StringDecode.decodeUTF16 will have all been replaced by `?`, so the test is effectively the same as testing ASCII-only.

Changes requested by bchristi (Reviewer).

test/micro/org/openjdk/bench/java/lang/StringDecode.java line 36:

> 34: @Warmup(iterations = 5, time = 2)
> 35: @Measurement(iterations = 5, time = 3)
> 36: @State(Scope.Thread)

No change to @Fork and @Warmup (as in the Encode test)?

test/micro/org/openjdk/bench/java/lang/StringDecode.java line 49:

> 47: public class StringDecode {
> 48: 
> 49:     @Param({"US-ASCII", "ISO-8859-1", "UTF-8", "MS932", "ISO-8859-6", "ISO-2022-KR"})

What would you think of retaining the previous set of charset names as a comment -- as a suggestion for someone who wants additional coverage?

test/micro/org/openjdk/bench/java/lang/StringDecode.java line 93:

> 91:     public void decodeAsciiLong(Blackhole bh) throws Exception {
> 92:         bh.consume(new String(longAsciiString, charset));
> 93:         bh.consume(new String(longAsciiString, 0, 1024 + 31, charset));

I imagine the 1024+31 addition gets compiled down, and is not executed during the test, right?

test/micro/org/openjdk/bench/java/lang/StringEncode.java line 39:

> 37: public class StringEncode {
> 38: 
> 39:     @Param({"US-ASCII", "ISO-8859-1", "UTF-8", "MS932", "ISO-8859-6"})

Same, re: keeping list as a comment.

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

PR: https://git.openjdk.java.net/jdk/pull/7516


More information about the core-libs-dev mailing list