Skip to content

Commit 583c3ef

Browse files
retronymmkeskells
andcommitted
Emit detailed compiler trace under -Yprofile-trace
Suitable for viewing directly in chrome://tracing, or post processing with https://github.com/retronym/chrome-trace-to-flamegraph Co-Authored-By: Mike Skells <[email protected]>
1 parent ebf8017 commit 583c3ef

File tree

13 files changed

+857
-205
lines changed

13 files changed

+857
-205
lines changed

project/ScriptCommands.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ object ScriptCommands {
109109
Project.setProject(session, newStructure, state)
110110
}
111111

112-
private[this] val enableOptimizer = Seq(
112+
val enableOptimizer = Seq(
113113
scalacOptions in Compile in ThisBuild ++= Seq("-opt:l:inline", "-opt-inline-from:scala/**")
114114
)
115115

116-
private[this] val noDocs = Seq(
116+
val noDocs = Seq(
117117
publishArtifact in (Compile, packageDoc) in ThisBuild := false
118118
)
119119

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,10 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
438438
currentRun.informUnitStarting(this, unit)
439439
val unit0 = currentUnit
440440
currentRun.currentUnit = unit
441+
currentRun.profiler.beforeUnit(phase, unit.source.file)
441442
try apply(unit)
442443
finally {
444+
currentRun.profiler.afterUnit(phase, unit.source.file)
443445
currentRun.currentUnit = unit0
444446
currentRun.advanceUnit()
445447
}
@@ -1100,6 +1102,9 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
11001102

11011103
def newJavaUnitParser(unit: CompilationUnit): JavaUnitParser = new JavaUnitParser(unit)
11021104

1105+
override protected[scala] def currentRunProfilerBeforeCompletion(root: Symbol, associatedFile: AbstractFile): Unit = currentRun.profiler.beforeCompletion(root, associatedFile)
1106+
override protected[scala] def currentRunProfilerAfterCompletion(root: Symbol, associatedFile: AbstractFile): Unit = currentRun.profiler.afterCompletion(root, associatedFile)
1107+
11031108
/** A Run is a single execution of the compiler on a set of units.
11041109
*/
11051110
class Run extends RunContextApi with RunReporting with RunParsing {
@@ -1448,7 +1453,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
14481453
private final val GlobalPhaseName = "global (synthetic)"
14491454
protected final val totalCompileTime = statistics.newTimer("#total compile time", GlobalPhaseName)
14501455

1451-
def compileUnits(units: List[CompilationUnit], fromPhase: Phase): Unit = compileUnitsInternal(units,fromPhase)
1456+
def compileUnits(units: List[CompilationUnit], fromPhase: Phase): Unit = compileUnitsInternal(units,fromPhase)
14521457
private def compileUnitsInternal(units: List[CompilationUnit], fromPhase: Phase) {
14531458
units foreach addUnit
14541459
reporter.reset()

0 commit comments

Comments
 (0)