Skip to content

8282047: Enhance StringDecode/Encode microbenchmarks#7516

Closed
cl4es wants to merge 7 commits intoopenjdk:masterfrom
cl4es:enc_dec_micros
Closed

8282047: Enhance StringDecode/Encode microbenchmarks#7516
cl4es wants to merge 7 commits intoopenjdk:masterfrom
cl4es:enc_dec_micros

Conversation

@cl4es
Copy link
Member

@cl4es cl4es commented Feb 17, 2022

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.

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8282047: Enhance StringDecode/Encode microbenchmarks

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/7516/head:pull/7516
$ git checkout pull/7516

Update a local copy of the PR:
$ git checkout pull/7516
$ git pull https://git.openjdk.java.net/jdk pull/7516/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 7516

View PR using the GUI difftool:
$ git pr show -t 7516

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/7516.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 17, 2022

👋 Welcome back redestad! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 17, 2022
@openjdk
Copy link

openjdk bot commented Feb 17, 2022

@cl4es The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Feb 17, 2022
@mlbridge
Copy link

mlbridge bot commented Feb 17, 2022

Webrevs

cl4es added a commit to cl4es/jdk that referenced this pull request Feb 17, 2022
@cl4es
Copy link
Member Author

cl4es commented Feb 24, 2022

Ping?

@State(Scope.Thread)
public class StringDecode {

@Param({"US-ASCII", "ISO-8859-1", "UTF-8", "MS932", "ISO-8859-6", "ISO-2022-KR"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@CompilerControl(CompilerControl.Mode.DONT_INLINE)
public void decodeAsciiLong(Blackhole bh) throws Exception {
bh.consume(new String(longAsciiString, charset));
bh.consume(new String(longAsciiString, 0, 1024 + 31, charset));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, adding two integer literals will be constant folded already by javac:

    public static void main(String...args) {
        int foo = 1024 + 31;
    }

javap -v output:

         0: sipush        1055
         3: istore_1
         4: return

@State(Scope.Thread)
public class StringEncode {

@Param({"US-ASCII", "ISO-8859-1", "UTF-8", "MS932", "ISO-8859-6"})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, re: keeping list as a comment.

@@ -46,22 +36,22 @@
@State(Scope.Thread)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change to @fork and @WarmUp (as in the Encode test)?

@Setup
public void setup() {
charset = Charset.forName(charsetName);
asciiString = LOREM.substring(0, 32).getBytes(charset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is problematic IMO in that it's missing short strings such as "Claes". Average Java strings are about 32 bytes long AFAICR, and people writing (vectorized) ijntrinsics have a nasty habit of optimizing for long strings, to the detriment of typical-length ones.
Whether we like it or not, people will optimize for benchmarks, so it's important that benchmark data is realistic. The shortest here is 15 bytes, as far as I can see. I'd certainly include a short string of just a few bytes so that intrinsics don't cause regressions in important cases.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good points. I've added a number of such short variants to all(?) relevant microbenchmarks. The tests should now better cover a mix of input lengths and encodings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@openjdk
Copy link

openjdk bot commented Feb 25, 2022

@cl4es This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8282047: Enhance StringDecode/Encode microbenchmarks

Reviewed-by: bchristi

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 87 new commits pushed to the master branch:

  • e96c599: 8271232: JFR: Scrub recording data
  • 735e86b: 8282345: handle latest VS2022 in abstract_vm_version
  • b96b743: 8281015: Further simplify NMT backend
  • 9471f24: 8280684: JfrRecorderService failes with guarantee(num_written > 0) when no space left on device.
  • 3efd6aa: 8282347: AARCH64: Untaken branch in has_negatives stub
  • cd36be4: 8206187: javax/management/remote/mandatory/connection/DefaultAgentFilterTest.java fails with Port already in use
  • bf19fc6: 8280357: user.home = "?" when running with systemd DynamicUser=true
  • b6843a1: 8005885: enhance PrintCodeCache to print more data
  • 23995f8: 8281525: Enable Zc:strictStrings flag in Visual Studio build
  • 20e78f7: 8282307: Parallel: Incorrect discovery mode in PCReferenceProcessor
  • ... and 77 more: https://git.openjdk.java.net/jdk/compare/b4900b1298e536c0ceaa77bc0ac0e8e6ccba6400...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Feb 25, 2022
@cl4es
Copy link
Member Author

cl4es commented Mar 1, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Mar 1, 2022

Going to push as commit d4d12ad.
Since your change was applied there have been 109 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 1, 2022
@openjdk openjdk bot closed this Mar 1, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 1, 2022
@openjdk
Copy link

openjdk bot commented Mar 1, 2022

@cl4es Pushed as commit d4d12ad.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants