Skip to content

Conversation

@liach
Copy link
Member

@liach liach commented Mar 30, 2023

This patch optimizes ClassDesc.resolveConstantDesc for array classes. Otherwise, the performance of reference class resolution remain unchanged.

A benchmark comparing resolution for reference arrays, primitive arrays, and class or interfaces is included in this patch, and the result comparison on my machine is available at https://jmh.morethan.io/?gists=21c462f4879f6166b3308a41c092d51e,1aeae6ff40a129f89dbfedcb874cfd37


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

Issue

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 13252

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 30, 2023

👋 Welcome back liach! 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 Mar 30, 2023
@openjdk
Copy link

openjdk bot commented Mar 30, 2023

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

@mlbridge
Copy link

mlbridge bot commented Mar 30, 2023

Webrevs

}

static boolean isPrimitiveArray(String referenceTypeDescriptorString) {
return referenceTypeDescriptorString.charAt(referenceTypeDescriptorString.length() - 1) != ';';
Copy link
Member

@mlchung mlchung Mar 30, 2023

Choose a reason for hiding this comment

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

it also needs to check if it starts with [

Suggested change
return referenceTypeDescriptorString.charAt(referenceTypeDescriptorString.length() - 1) != ';';
return referenceTypeDescriptorString.startsWith("[") &&
referenceTypeDescriptorString.charAt(referenceTypeDescriptorString.length() - 1) != ';';

Copy link
Member Author

Choose a reason for hiding this comment

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

I intend this to be a ReferenceClassDesc-specifc check. I think moving isPrimitiveArray as a private method in ReferenceClassDesc would be better, as the startsWith("[") is already implied (at least before valhalla, non-array, i.e. class or interface descriptors must end with a semicolon.

Comment on lines 115 to 120
NEW {
@Override
Class<?> call(MethodHandles.Lookup lookup, ClassDesc cd) throws ReflectiveOperationException {
return resolveReference(lookup, cd);
}
},
Copy link
Member

Choose a reason for hiding this comment

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

I think this benchmark doesn't need this case as that's the implementation of resolveConstantDesc. Was it there when you developed this fix? Same for MethodTypeDesc benchmark.

@Measurement(iterations = 6, time = 1)
@Fork(1)
@State(Scope.Benchmark)
public class MethodTypeDescResolve {
Copy link
Member

Choose a reason for hiding this comment

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

Better to separate this benchmark from this PR. Probably the optimization done in PR 10991 should be a separate patch from JDK-8294961 and this benchmark could be included there.

@liach
Copy link
Member Author

liach commented Mar 31, 2023

Done. Now the benchmark explicitly measures the 3 reference types, with new result in line with previous observations here: https://jmh.morethan.io/?gists=21c462f4879f6166b3308a41c092d51e,1aeae6ff40a129f89dbfedcb874cfd37

The isPrimitiveArray check is converted to a private method in ReferenceClassDesc as it applies only to reference type descriptor strings. Also included the rationale for not checking initial [ in a comment.

@liach
Copy link
Member Author

liach commented Mar 31, 2023

If you don't mind, please also check out #12986, which avoids casting the result to Class after calling ClassDesc::resolveConstantDesc.

@mlchung
Copy link
Member

mlchung commented Mar 31, 2023

The isPrimitiveArray check is converted to a private method in ReferenceClassDesc as it applies only to reference type descriptor strings. Also included the rationale for not checking initial [ in a comment.

This would work.

Copy link
Member

@mlchung mlchung left a comment

Choose a reason for hiding this comment

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

Looks good. The new benchmark is cleaner.

@openjdk
Copy link

openjdk bot commented Mar 31, 2023

@liach 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:

8304928: Optimize ClassDesc.resolveConstantDesc

Reviewed-by: mchung

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 8 new commits pushed to the master branch:

  • 345669c: 8302738: IGV: refine 'Simplify graph' filter
  • dea9db2: 8305055: IR check fails on some aarch64 platforms
  • c8f3a97: 8305171: PPC: Should use IMA::load_resolved_indy_entry() in TIG::generate_return_entry_for()
  • 7fe5bd2: 8305174: disable dtrace for s390x builds
  • 787832a: 8304988: unnecessary dash in @param gives double-dash in docs
  • a144c71: 8305008: RISC-V: Factor out immediate checking functions from assembler_riscv.inline.hpp
  • d815889: 8304993: bad sentence break in DateFormat
  • 5f7b4b8: 8305111: Locale.lookupTag has typo in parameter

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@mlchung) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 31, 2023
@liach
Copy link
Member Author

liach commented Mar 31, 2023

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Mar 31, 2023
@openjdk
Copy link

openjdk bot commented Mar 31, 2023

@liach
Your change (at version c347939) is now ready to be sponsored by a Committer.

@mlchung
Copy link
Member

mlchung commented Mar 31, 2023

/sponsor

@openjdk
Copy link

openjdk bot commented Mar 31, 2023

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

  • bdbf8fc: 8303930: Fix ConstantUtils.skipOverFieldSignature void case return value
  • 4a5d7ca: 8305227: [s390x] build broken after JDK-8231349
  • dae1ab3: 8304844: JFR: Missing disk parameter in ActiveRecording event
  • e012685: 8305066: [JVMCI] guarantee(ik->is_initialized()) failed: java/lang/Long$LongCache must be initialized
  • fe42312: 8304820: Statically allocate ObjectSynchronizer mutexes
  • 2f36eb0: 8305323: Update java/net/httpclient/ContentLengthHeaderTest.java to use new HttpTestServer factory methods
  • 049b953: 8305223: IGV: mark osr compiled graphs with [OSR] in the name
  • 345669c: 8302738: IGV: refine 'Simplify graph' filter
  • dea9db2: 8305055: IR check fails on some aarch64 platforms
  • c8f3a97: 8305171: PPC: Should use IMA::load_resolved_indy_entry() in TIG::generate_return_entry_for()
  • ... and 5 more: https://git.openjdk.org/jdk/compare/83cf28f99639d80e62c4031c4c9752460de5f36c...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 31, 2023

@mlchung @liach Pushed as commit cccb019.

💡 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 [email protected] integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

2 participants