stream: don't create AbruptTerminationException in happy case (#28686)

Turned up in heavy stream materialization churn benchmark.
This commit is contained in:
Johannes Rudolph 2020-03-04 17:11:23 +01:00 committed by GitHub
parent 3157b0199b
commit 655dfbc67f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -794,10 +794,12 @@ import scala.util.control.NonFatal
newShells.map(shell => shell.toSnapshot.asInstanceOf[UninitializedInterpreter]))
}
override def postStop(): Unit = {
val ex = AbruptTerminationException(self)
activeInterpreters.foreach(_.tryAbort(ex))
activeInterpreters = Set.empty[GraphInterpreterShell]
newShells.foreach(s => if (tryInit(s)) s.tryAbort(ex))
}
override def postStop(): Unit =
// avoid creating exception in happy case since it uses self.toString which is somewhat slow
if (activeInterpreters.nonEmpty || newShells.nonEmpty) {
val ex = AbruptTerminationException(self)
activeInterpreters.foreach(_.tryAbort(ex))
activeInterpreters = Set.empty[GraphInterpreterShell]
newShells.foreach(s => if (tryInit(s)) s.tryAbort(ex))
}
}