-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8263452: Javac slow compilation due to algorithmic complexity #3523
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
Conversation
👋 Welcome back jlahoda! A progress list of the required criteria for merging this PR into |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks sensible
@lahodaj 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:
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 442 new commits pushed to the
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 |
@@ -5089,14 +5089,17 @@ void attribClass(ClassSymbol c) throws CompletionFailure { | |||
chk.checkNonCyclic(null, c.type); | |||
|
|||
Type st = types.supertype(c.type); | |||
if ((c.flags_field & Flags.COMPOUND) == 0) { | |||
if ((c.flags_field & Flags.COMPOUND) == 0 && | |||
(c.flags_field & Flags.SUPER_OWNER_ATTRIBUTED) == 0) { | |||
// First, attribute superclass. | |||
if (st.hasTag(CLASS)) | |||
attribClass((ClassSymbol)st.tsym); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a guarding against a special case of attributing something twice. Did you consider pushing this into attribClass instead so that calling it a second time is a no-op?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jbf, sorry, I missed you comment.
I was thinking of using Flags.UNATTRIBUTED
and skipping this whole method. I was a bit worried about a case where a class from source has a supertype from classfile (which never has UNATTRIBUTED
), which has a supertype from source - by using UNATTRIBUTED
, we could get to a state where this supertype attribution wouldn't attribute the super-supertype from source. Using another flag is an attempt to avoid this issue completely - the cost is using one more flag out of a limited pool of flags, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, though you should probably get a second reviewer.
/integrate |
@lahodaj Since your change was applied there have been 512 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 8468001. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Consider a class that extends its enclosing class. There are a few places in javac where javac does some actions for the supertype and enclosing class, doing these actions twice in this scenario. If the enclosing class also extends its enclosing class, and its enclosing type does as well, etc., these checks are done for the enclosing classes, and the number of actions grows exponentially.
Even though this seems like a rare case, we can improve javac by avoiding redoing the checks that were already done. There are two parts:
-
Check.checkNonCyclicDecl
will not record the hierarchy is acyclic if a supertype uses a full-qualified name, as it considers the hierarchy to be "partial", as it only considers hierarchies non-partial if all super AST nodes are filled with class symbols. The proposed solution is to not mark the hierarchy as partial if a part of the FQN is attributed as a package symbol. As a side tweak, the cycle detector is now proposed to be a Set rather than a List, to improve lookup times.-in
attribClass
, first the superclass and enclosing class of the current class are attributed, but these are done even if already done, and in the case of the class hierarchy described here these no-op attributions can be done very many times. The proposed fix is to do the attribution of super/enclosing only once.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3523/head:pull/3523
$ git checkout pull/3523
Update a local copy of the PR:
$ git checkout pull/3523
$ git pull https://git.openjdk.java.net/jdk pull/3523/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3523
View PR using the GUI difftool:
$ git pr show -t 3523
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3523.diff