mirror of https://github.com/sbt/sbt.git
Don't do progress work on the main thread
I noticed that no-op compile was slower in
https://github.com/sbt/sbt/issues/5508 using 1.4.0-RC2 than 1.4.0-RC1.
It took around 400ms with 1.4.0-RC2 and 200-250ms on RC1. Git bisect
brought me to 41afe9fbdb which I
remembered I'd been slightly concerned about from a performance
perspective but didn't get around to testing. The problem is that we
were blocking the task from running while determing whether or not we
should force a progress report. We can do that work on the background
thread instead so the task can begin running immediately.
This commit is contained in:
parent
4ec6339794
commit
d930cb1987
|
|
@ -107,10 +107,15 @@ private[sbt] class TaskProgress(
|
|||
|
||||
override def afterReady(task: Task[_]): Unit =
|
||||
if (!closed.get) {
|
||||
if (skipReportTasks.contains(getShortName(task))) {
|
||||
lastTaskCount.set(-1) // force a report for remote clients
|
||||
report()
|
||||
} else Util.ignoreResult(active.put(task, schedule(threshold, recurring = false)(doReport())))
|
||||
try {
|
||||
Util.ignoreResult(executor.submit((() => {
|
||||
if (skipReportTasks.contains(getShortName(task))) {
|
||||
lastTaskCount.set(-1) // force a report for remote clients
|
||||
report()
|
||||
} else
|
||||
Util.ignoreResult(active.put(task, schedule(threshold, recurring = false)(doReport())))
|
||||
}): Runnable))
|
||||
} catch { case _: RejectedExecutionException => }
|
||||
} else {
|
||||
logger.debug(s"called afterReady for ${taskName(task)} after task progress was closed")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue