Merge pull request #5125 from eatkins/progress-improvements

Progress improvements
This commit is contained in:
Ethan Atkins 2019-09-24 13:34:28 -07:00 committed by GitHub
commit aac37b4346
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 26 deletions

View File

@ -224,13 +224,15 @@ object EvaluateTask {
structure: BuildStructure, structure: BuildStructure,
state: State state: State
): ExecuteProgress[Task] = { ): ExecuteProgress[Task] = {
state.get(currentTaskProgress).map(_.progress).getOrElse {
val maker: Seq[Keys.TaskProgress] = getSetting( val maker: Seq[Keys.TaskProgress] = getSetting(
Keys.progressReports, Keys.progressReports,
Seq(), Seq(),
extracted, extracted,
structure structure
) )
val progressReporter = extracted.get(progressState in ThisBuild).map { ps => val progressReporter = extracted.getOpt(progressState in ThisBuild).flatMap {
case Some(ps) =>
ps.reset() ps.reset()
ConsoleAppender.setShowProgress(true) ConsoleAppender.setShowProgress(true)
val appender = MainAppender.defaultScreen(StandardMain.console) val appender = MainAppender.defaultScreen(StandardMain.console)
@ -239,7 +241,8 @@ object EvaluateTask {
case _ => case _ =>
} }
val log = LogManager.progressLogger(appender) val log = LogManager.progressLogger(appender)
new TaskProgress(log) Some(new TaskProgress(log))
case _ => None
} }
val reporters = maker.map(_.progress) ++ progressReporter ++ val reporters = maker.map(_.progress) ++ progressReporter ++
(if (SysProp.taskTimings) new TaskTimings(reportOnShutdown = false) :: Nil else Nil) (if (SysProp.taskTimings) new TaskTimings(reportOnShutdown = false) :: Nil else Nil)
@ -249,6 +252,7 @@ object EvaluateTask {
case xs => ExecuteProgress.aggregate[Task](xs) case xs => ExecuteProgress.aggregate[Task](xs)
} }
} }
}
// TODO - Should this pull from Global or from the project itself? // TODO - Should this pull from Global or from the project itself?
private[sbt] def forcegc(extracted: Extracted, structure: BuildStructure): Boolean = private[sbt] def forcegc(extracted: Extracted, structure: BuildStructure): Boolean =
getSetting(Keys.forcegc in Global, GCUtil.defaultForceGarbageCollection, extracted, structure) getSetting(Keys.forcegc in Global, GCUtil.defaultForceGarbageCollection, extracted, structure)

View File

@ -482,6 +482,7 @@ object Keys {
object TaskProgress { object TaskProgress {
def apply(progress: ExecuteProgress[Task]): TaskProgress = new TaskProgress(progress) def apply(progress: ExecuteProgress[Task]): TaskProgress = new TaskProgress(progress)
} }
private[sbt] val currentTaskProgress = AttributeKey[TaskProgress]("current-task-progress")
val useSuperShell = settingKey[Boolean]("Enables (true) or disables the super shell.") val useSuperShell = settingKey[Boolean]("Enables (true) or disables the super shell.")
val turbo = settingKey[Boolean]("Enables (true) or disables optional performance features.") val turbo = settingKey[Boolean]("Enables (true) or disables optional performance features.")
// This key can be used to add custom ExecuteProgress instances // This key can be used to add custom ExecuteProgress instances

View File

@ -179,10 +179,18 @@ object MainLoop {
val channelName = exec.source map (_.channelName) val channelName = exec.source map (_.channelName)
StandardMain.exchange publishEventMessage StandardMain.exchange publishEventMessage
ExecStatusEvent("Processing", channelName, exec.execId, Vector()) ExecStatusEvent("Processing", channelName, exec.execId, Vector())
try { try {
def process(): State = { def process(): State = {
val newState = Command.process(exec.commandLine, state) val progressState = state.get(sbt.Keys.currentTaskProgress) match {
case Some(_) => state
case _ =>
if (state.get(Keys.stateBuildStructure).isDefined) {
val extracted = Project.extract(state)
val progress = EvaluateTask.executeProgress(extracted, extracted.structure, state)
state.put(sbt.Keys.currentTaskProgress, new Keys.TaskProgress(progress))
} else state
}
val newState = Command.process(exec.commandLine, progressState)
if (exec.commandLine.contains("session")) if (exec.commandLine.contains("session"))
newState.get(hasCheckedMetaBuild).foreach(_.set(false)) newState.get(hasCheckedMetaBuild).foreach(_.set(false))
val doneEvent = ExecStatusEvent( val doneEvent = ExecStatusEvent(
@ -198,7 +206,8 @@ object MainLoop {
} else { // send back a notification } else { // send back a notification
StandardMain.exchange publishEventMessage doneEvent StandardMain.exchange publishEventMessage doneEvent
} }
newState newState.get(sbt.Keys.currentTaskProgress).foreach(_.progress.stop())
newState.remove(sbt.Keys.currentTaskProgress)
} }
// The split on space is to handle 'reboot full' and 'reboot'. // The split on space is to handle 'reboot full' and 'reboot'.
state.currentCommand.flatMap(_.commandLine.trim.split(" ").headOption) match { state.currentCommand.flatMap(_.commandLine.trim.split(" ").headOption) match {

View File

@ -73,7 +73,7 @@ private[sbt] final class TaskProgress(log: ManagedLogger)
private[this] val skipReportTasks = private[this] val skipReportTasks =
Set("run", "bgRun", "fgRun", "scala", "console", "consoleProject", "consoleQuick", "state") Set("run", "bgRun", "fgRun", "scala", "console", "consoleProject", "consoleQuick", "state")
private[this] def report(): Unit = { private[this] def report(): Unit = {
val currentTasks = activeTasks.toVector val currentTasks = activeTasks.toVector.filterNot(Def.isDummy)
val ltc = lastTaskCount.get val ltc = lastTaskCount.get
val currentTasksCount = currentTasks.size val currentTasksCount = currentTasks.size
def report0(): Unit = { def report0(): Unit = {