Skip to content

Conversation

@wenshao
Copy link
Contributor

@wenshao wenshao commented Nov 10, 2024

StringUTF16#putChar is a trusted caller missed bounds check, which makes -COMPACT_STRINGS perform better than +COMPACT_STRINGS in the scenarios of Integer/Long.toString and StringBuilder#append(int/long). I think this is not the performance number we expect.

Below are the performance numbers running under AMD EPYC™ Genoa (x64)

  • benchmark script
git remote add wenshao [email protected]:wenshao/jdk.git
git fetch wenshao

# master
git checkout 37387d8a27dacb52e2c9fe44852b42c899572619
make test TEST="micro:java.lang.StringBuilders.appendWithInt"
make test TEST="micro:java.lang.StringBuilders.appendWithLong"

# current
git checkout 661fccf05053bda7428bbb0c36a4d15144c94d62
make test TEST="micro:java.lang.StringBuilders.appendWithInt"
make test TEST="micro:java.lang.StringBuilders.appendWithLong"
  • benchmark numbers
# master 37387d8a27dacb52e2c9fe44852b42c899572619
Benchmark                           Mode  Cnt    Score   Error  Units
StringBuilders.appendWithIntLatin1  avgt   15  225.953 ± 0.923  ns/op
StringBuilders.appendWithIntUtf16   avgt   15  212.090 ± 1.172  ns/op

Benchmark                            Mode  Cnt    Score   Error  Units
StringBuilders.appendWithLongLatin1  avgt   15  227.951 ± 3.702  ns/op
StringBuilders.appendWithLongUtf16   avgt   15  211.267 ± 1.914  ns/op

# current 661fccf05053bda7428bbb0c36a4d15144c94d62
Benchmark                           Mode  Cnt    Score   Error  Units
StringBuilders.appendWithIntLatin1  avgt   15  192.433 ± 0.956  ns/op +17%
StringBuilders.appendWithIntUtf16   avgt   15  210.805 ± 0.624  ns/op

Benchmark                            Mode  Cnt    Score   Error  Units
StringBuilders.appendWithLongLatin1  avgt   15  191.443 ± 1.533  ns/op +19%
StringBuilders.appendWithLongUtf16   avgt   15  210.444 ± 1.118  ns/op

In the master version, we can see that the performance of appendWithIntLatin1 is worse than that of appendWithIntUtf16.

In the current version, based on the unsafe implementation of putChar, the performance of appendWithIntLatin1 and appendWithLongLatin1 has increased by 17% and 19% respectively, which means that the performance of appendWithIntLatin1 exceeds that of appendWithIntUtf16.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22000/head:pull/22000
$ git checkout pull/22000

Update a local copy of the PR:
$ git checkout pull/22000
$ git pull https://git.openjdk.org/jdk.git pull/22000/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22000

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22000.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 10, 2024

👋 Welcome back swen! 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
Copy link

openjdk bot commented Nov 10, 2024

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk
Copy link

openjdk bot commented Nov 10, 2024

@wenshao 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.

@liach
Copy link
Member

liach commented Nov 10, 2024

Tests look good. The only left usages of explicit byte array assignments (search for ] = ) are in replace and toUpperCase and toLowerCase.

@wenshao
Copy link
Contributor Author

wenshao commented Nov 11, 2024

PR #21593 already contains the current changes, so close the current PR

@wenshao wenshao closed this Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants