Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8265602: -XX:DumpLoadedClassList should support custom loaders #4952

Closed

Conversation

iklam
Copy link
Member

@iklam iklam commented Aug 2, 2021

Some applications load a lot of classes using custom loaders. This PR improves the start-up performance of these apps when using a "static" CDS archive:

Here are performance numbers for the Eclipse IDE:

Static Archive Before: 7.31 sec (classlist does not include custom loader classes)
Static Archive After:  6.49 sec (classlist includes custom loader classes)
Dynamic Archive:       6.62 sec

Progress

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

Issue

  • JDK-8265602: -XX:DumpLoadedClassList should support custom loaders

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 4952

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 2, 2021

👋 Welcome back iklam! 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 Aug 2, 2021

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

  • hotspot

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 hotspot hotspot-dev@openjdk.org label Aug 2, 2021
@iklam
Copy link
Member Author

iklam commented Aug 2, 2021

/label remove hotspot
/label add hotspot-runtime

@openjdk openjdk bot removed the hotspot hotspot-dev@openjdk.org label Aug 2, 2021
@openjdk
Copy link

openjdk bot commented Aug 2, 2021

@iklam
The hotspot label was successfully removed.

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Aug 2, 2021
@openjdk
Copy link

openjdk bot commented Aug 2, 2021

@iklam
The hotspot-runtime label was successfully added.

@iklam iklam marked this pull request as ready for review August 2, 2021 06:57
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 2, 2021
@mlbridge
Copy link

mlbridge bot commented Aug 2, 2021

Webrevs

@@ -330,23 +330,24 @@ void ReadClosure::do_region(u_char* start, size_t size) {
}
}

fileStream* ClassListWriter::_classlist_file = NULL;

void ArchiveUtils::log_to_classlist(BootstrapInfo* bootstrap_specifier, TRAPS) {
if (ClassListWriter::is_enabled()) {
if (SystemDictionaryShared::is_supported_invokedynamic(bootstrap_specifier)) {
ResourceMark rm(THREAD);
Copy link
Member

Choose a reason for hiding this comment

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

Line 336 could be moved after line 338.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines +53 to +54
void ClassListWriter::write(const InstanceKlass* k, const ClassFileStream* cfs) {
assert(is_enabled(), "must be");
Copy link
Member

Choose a reason for hiding this comment

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

Should assert_locked() be added here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This function doesn't need the lock, since it doesn't directly use ClassListWriter::_classlist_file or ClassListWriter::_id_table, which are protected by ClassListFile_lock. The lock will be taken a few lines down, in the ClassListWriter constructor.

Your comment reminded me to look for places that need the lock. As a result, I added assert_locked() to ClassListWriter::write_to_stream().

#else
public:
static bool is_enabled() {
return false;
}
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Please add // INCLUDE_CDS after endif.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines +25 to +30
public class CustomLoadee4WithLambda {
public static void test() {
doit(() -> {
System.out.println("Hello inside a Lambda expression");
});
}
Copy link
Member

Choose a reason for hiding this comment

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

We have a similar class in dynamicArchive/test-classes/LambHello.java.
To avoid changes in existing tests, maybe you can just add a test() method there.

Copy link
Member Author

Choose a reason for hiding this comment

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

LambHello is in a separate directory and is used by several existing tests that require the function doTest(). If I add another test() function there it kind of looks odd. Also, I don't want to introduce inter-dependencies between too many tests. Since this class is small, I prefer to keep it separate.

Copy link
Member

@calvinccheung calvinccheung 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. Just a few minor comments.

Copy link
Contributor

@yminqi yminqi 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!
One concern is that this patch works for custom class in a plain jar file, but won't work with if the class loader has its own way to load class from more complicated location like "fat" jar, is it correct?

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a new file?

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, it is a new file. In my first commit I included 2016 in the copyright by mistake, so I removed it in the second commit.

@iklam
Copy link
Member Author

iklam commented Aug 4, 2021

Looks good!
One concern is that this patch works for custom class in a plain jar file, but won't work with if the class loader has its own way to load class from more complicated location like "fat" jar, is it correct?

That's correct, I have filed JDK-8271598 (CDS classlist file should support uber JARs) to handle this issue.

@openjdk
Copy link

openjdk bot commented Aug 4, 2021

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

8265602: -XX:DumpLoadedClassList should support custom loaders

Reviewed-by: ccheung, minqi

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 Aug 4, 2021
Copy link
Member

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

@iklam
Copy link
Member Author

iklam commented Aug 6, 2021

Thanks @calvinccheung and @yminqi for the review.
/integrate

@openjdk
Copy link

openjdk bot commented Aug 6, 2021

Going to push as commit e7b6f48.
Since your change was applied there has been 1 commit pushed to the master branch:

  • ea02dad: 8272067: Initial nroff manpage generation for JDK 18

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Aug 6, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated labels Aug 6, 2021
@openjdk openjdk bot removed the rfr Pull request is ready for review label Aug 6, 2021
@openjdk
Copy link

openjdk bot commented Aug 6, 2021

@iklam Pushed as commit e7b6f48.

💡 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
hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants