[java] Don't use ClassNotFoundException to report unresolved classes#2236
Merged
Conversation
This speeds up type resolution by a factor of 2.
Generated by 🚫 Danger |
adangel
approved these changes
Feb 16, 2020
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
So I was fiddling with Intellij's profiler, and found out that the constructor of ClassNotFoundException slows down classloading by a huge factor. In all usages that matter, the exception is immediately caught by the caller and ignored.
With this change we return null instead. This speeds up type resolution by a factor of 2.
Here's a comparison on the sources of OpenJDK 12 (around 17700 source files):
Bonus: I tried the same thing with my prototype for 7.0, and got these results:
So it's nearly 4 times faster than current master. Note that the time is spent in the rule rather than in the processing stage. That's because it's done on demand by the rule. This sample rule resolves all TypeNodes in the tree though. "Qualified name resolution" and "Symbol table resolution" are sub tasks of "Java Processing".