-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Improve performance of the backend #5820
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b3975a5
Optimize label defs finder in the backend
retronym 7a6dc1a
Avoid excessive file stats during classfile writing
retronym 455729e
Use AnyRefMap in labelReferences
retronym 53dd4e4
Cache ClassSymbol.javaBinaryNameString
retronym 1ae858c
Remove expensive assertion in the backend
retronym bebb188
Optimize method descriptor creation
retronym 070ab67
Review feedback: resurrect assertion, use LabelDefFinder.apply
retronym 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
Avoid excessive file stats during classfile writing
The existing implementation pessimistically checks that all parent directories of the about-to-be-written class file are indeed directories. This commit bypasses this logic for the common case of writing to a regular directory on disk, and optimistically assumes that the parent directory exists. If an exception is thrown during writing, it attempts to create the parent directory. This still avoids a compiler crash if a parent directory is actually a file, which is tested by the existing test, `run/t5717.scala`.
- Loading branch information
commit 7a6dc1abbfc9afda27623dd43424c252dcec8088
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.
would it be too slow to check
java.nio.file.Files.exists(p.getParent)
?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 found some small but measurable improvement from this approach, as there are typically many classfiles per directory, which makes the optimism pays off. I could split this into two commits so that we could reproduce that measurement.
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 that there is a better solution in #5815, that will only check a given directory once, and will not call createDirectories unless it the first time that the directory is reached
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.
@lrytz each stat call is expensive in windows particually
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 like the approach of caching the results of file stats, but opted not to do that in this PR because it takes a bit of care to get the lifecycle of that cache sorted out (we need to start fresh on a new compiler run, but the current design of
ByteCodeWriters
didn't have a hook for that part of the lifecycle.)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.
@retronym it is hooked in this my PR as the OutputDirectories are created new for each run
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 have split out an alternative as #5834
will run performance test overnight and post up is successful