-
Notifications
You must be signed in to change notification settings - Fork 1.1k
report phases/units via xsbti.compile.CompileProgress.startUnit #13082 #13084
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
3 commits
Select commit
Hold shift + click to select a range
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package xsbt | ||
|
||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class CompileProgressReportTest: | ||
|
||
@Test | ||
def testStartUnitReports(): Unit = | ||
val source1 = | ||
"""class A { | ||
| | ||
|} | ||
|""".stripMargin | ||
|
||
val compilerForTesting = new ScalaCompilerForUnitTesting | ||
val progress = compilerForTesting.compileSrcs(source1)._3 | ||
|
||
val expectedProgress = Seq( | ||
("Test-0-0.scala", "typer (parsing)"), | ||
("Test-0-0.scala", "typer (typechecking)"), | ||
("Test-0-0.scala", "typer (checking java)"), | ||
("Test-0-0.scala", "inlinedPositions"), | ||
("Test-0-0.scala", "sbt-deps"), | ||
("Test-0-0.scala", "posttyper"), | ||
("Test-0-0.scala", "sbt-api"), | ||
("Test-0-0.scala", "pickler"), | ||
("Test-0-0.scala", "inlining"), | ||
("Test-0-0.scala", "postInlining"), | ||
("Test-0-0.scala", "staging"), | ||
("Test-0-0.scala", "pickleQuotes"), | ||
("Test-0-0.scala", "MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, betaReduce, inlineVals, expandSAMs}"), | ||
("Test-0-0.scala", "MegaPhase{elimRepeated, protectedAccessors, extmethods, uncacheGivenAliases, byNameClosures, hoistSuperArgs, specializeApplyMethods, refchecks}"), | ||
("Test-0-0.scala", "MegaPhase{elimOpaque, tryCatchPatterns, patternMatcher, explicitOuter, explicitSelf, elimByName, stringInterpolatorOpt}"), | ||
("Test-0-0.scala", "MegaPhase{pruneErasedDefs, uninitializedDefs, inlinePatterns, vcInlineMethods, seqLiterals, intercepted, getters, specializeFunctions, liftTry, collectNullableFields, elimOuterSelect, resolveSuper, functionXXLForwarders, paramForwarding, genericTuples, letOverApply, arrayConstructors}"), | ||
("Test-0-0.scala", "erasure"), | ||
("Test-0-0.scala", "MegaPhase{elimErasedValueType, pureStats, vcElideAllocations, arrayApply, elimPolyFunction, tailrec, completeJavaEnums, mixin, lazyVals, memoize, nonLocalReturns, capturedVars}"), | ||
("Test-0-0.scala", "constructors"), | ||
("Test-0-0.scala", "MegaPhase{lambdaLift, elimStaticThis, countOuterAccesses}"), | ||
("Test-0-0.scala", "MegaPhase{dropOuterAccessors, checkNoSuperThis, flatten, renameLifted, transformWildcards, moveStatic, expandPrivate, restoreScopes, selectStatic, collectSuperCalls, repeatableAnnotations}"), | ||
("Test-0-0.scala", "genBCode") | ||
) | ||
|
||
val actualProgress = progress.startUnitCalls.map { case (phase, filePath0) => | ||
val filePath = filePath0.replace("\\", "/") // for Windows | ||
val fileNameShort = filePath.substring(filePath.lastIndexOf("/") + 1, filePath.length) | ||
(fileNameShort, phase) | ||
} | ||
|
||
// .mkString("\n") for better diff view | ||
assertEquals(expectedProgress.mkString("\n"), actualProgress.mkString("\n")) |
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
Oops, something went wrong.
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.
These "MegaPhase" phase names are not ideal, but I don't know how to better report them ATM, taking into account that all subphases are reported for each file
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.
Maybe just the first name, e.g. "miniphases following firstTransform"?
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.
Hmm, not sure if there should be information loss.
This could probably be done on the client-side, by parsing.
It has quite a simple structure for that.
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.
Also, maybe we could create meaningful names for each MegaPhase, and report it?
I just do not have enough expertise in the compiler to give proper names to them.
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.
If we could, we would just put all mini-phases in a single MegaPhase (since that would result in a single pass over the AST), but because of implementation details that's not possible, so we split them into the minimum number of MegaPhases we can, but these MegaPhases are not meaningful on their own, so there's no useful name we can give them. In fact, I don't think the name of phases in general is useful information for end users, you could just as well use numbers ("Running phase 1/6 ...") or nothing at all ("Compiling ..."), since the number isn't very useful either.
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.
We do not print the information about the phases as text anywhere.
It's only reported in the Compilation Charts
https://blog.jetbrains.com/scala/2021/04/07/intellij-scala-plugin-2021-1/#phases-and-units-in-compilation-charts
Yes, most of the users are not interested in this, but there were some users (Scala 2), dealing with macro and compiler internals, which reported their interest in this kind of information.
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.
Anyway, until I can call
advance
method, this method call will tell IDE that the compilation process is not stuck.(currently, compilation can take minutes without any indication of progress)
Any value will be fine.