Skip to content

Commit

Permalink
Remove overhead of stacked names in macro inst
Browse files Browse the repository at this point in the history
  • Loading branch information
jvican committed May 31, 2018
1 parent 5cca58c commit 383a60d
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,16 @@ final class ProfilingImpl[G <: Global](
private val macroIdsToTimers = perRunCaches.newMap[Int, statistics.Timer]()
private val macroChildren = perRunCaches.newMap[Int, List[MacroEntry]]()
private val stackedNanos = perRunCaches.newMap[Int, Long]()
private val stackedNames = perRunCaches.newMap[Int, String]()
private val stackedNames = perRunCaches.newMap[Int, List[String]]()

def foldMacroStacks(outputPath: Path): Unit = {
// This part is memory intensive and hence the use of java collections
val stacksJavaList = new java.util.ArrayList[String]()
stackedNanos.foreach {
case (id, nanos) =>
val stackName =
val names =
stackedNames.getOrElse(id, sys.error(s"Stack name for macro id ${id} doesn't exist!"))
val stackName = names.mkString(";")
stacksJavaList.add(s"$stackName ${nanos / 1000}")
}
java.util.Collections.sort(stacksJavaList)
Expand Down Expand Up @@ -529,16 +530,15 @@ final class ProfilingImpl[G <: Global](
case None => sys.error("Fatal error: macro has no state!")
}

stackedNames.update(macroId, thisStackName)
stackedNames.update(macroId, thisStackName :: Nil)
children.foreach { childSearch =>
val id = childSearch.id
val childrenStackName = stackedNames.getOrElse(id, sys.error("no stack name"))
stackedNames.update(id, s"$thisStackName;$childrenStackName")
stackedNames.update(id, thisStackName :: childrenStackName)
}
}

statistics.stopTimer(macroTimer, head.start)
// TODO: Why are we getting the previous nanos first?
val previousNanos = stackedNanos.getOrElse(macroId, 0L)
stackedNanos.+=((macroId, macroTimer.nanos + previousNanos))
prevData match {
Expand Down

0 comments on commit 383a60d

Please sign in to comment.