-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8369039: JDK-8348611 caused regression in Javac-Hot-Generate #27651
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f992660
Avoid unnecessary recursion in LintMapper.
archiecobbs d098d01
Avoid using LintMapper when knowing rootLint suffices.
archiecobbs 02d2e73
Remove drive-by tweaks that aren\t the real issue.
archiecobbs fdc907a
Put back the drive-by tweaks; they seem to matter.
archiecobbs 816162e
Unstream loops.
archiecobbs c7d5d30
Do more desugaring of Stream and Optional.
archiecobbs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
LinkedList has a ton of nodes, which translate to extra object headers, forward/backward pointers, and worse cache locality. To add N items, it requires O(N) allocations. In contrast, ArrayList requires O(log(N)) allocations (resizing) and is almost always better.
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.
@archiecobbs measured a win. I haven't seen it in profiles but it could be that the code in
afterAttrcontribute to the case forLinkedListas it is set up to remove matching item from the list, likely at an early index. Which is one of the few things aLinkedListactually does better than anArrayList.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.
While I agree
ArrayLists are often better, @archiecobbs measured theLinkedLists perform better here, as @cl4es says.I am not quite clear why linked lists are faster, but it might be many of the lists are either empty (all the
childrenof the leafLintRangeinstances will be empty lists, I think, and an emptyLinkedListis, I think, cheaper than an emptyArrayList), and some of them will have only a few entries (like theunmappedDeclslist here: AFAIK, this has one entry for each top-level declaration, and hence is highly unlikely to have more than 2 entries - one for the package clause, and one for the top-level class). IfArrayLists with substantial number of entries are only a small minority, it might explain why the use ofLinkedLists leads to better results.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.
I think the right way to fix is not to use LinkedList, but to update afterAttr to use List.removeIf - this was added back in 8 to avoid the overhead of shifting from multiple removals.
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.
On second look my last analysis was wrong. This is removing one element which is probably better done as an operation on a TreeSet, which is okay. However, I don't find why we would use a LinkedList for LintRange.
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.
Actually it will most likely only have one entry - package declarations are not included because they can never contain
@SuppressWarningsannotations. This may explain whyLinkedListis faster on average.The same answer may apply here, but honestly I'm just guessing at this. I was also surprised that
LinkedListwas faster thanArrayList, but the numbers seem to be saying that.In fact, as you point out,
unmappedDeclscould be aSetinstead of aList. But whether that would actually help is not clear.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.
Argh, ignore that, I was looking at something else. So "2" is the right number on average.
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.
But there's no reason for that! 99.99% of package declarations have no annotations and therefore do not need to wait for attribution. So we can get this number down to "1".
I was curious if that would make any difference (using this additional patch). When I try it on my laptop I get a slight improvement:
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.
Can't reallt establish any statistically significant difference either way here, neither on score or allocations.
So just to understand this a bit better I instrumented to see how common that condition is and it seems that when
tree.getTag() == Tree.PACKAGEDEFthentree.annotationsis never empty. At least in this benchmark. Perhaps the case when there are no annotations are skipped earlier?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.
Really? I'm not seeing that. When I apply this patch, I see
size=0unless there's actually an annotation there: