mirror of https://github.com/sbt/sbt.git
Fix performance regression in test classloader
In 5eab9df0df, I updated the
outputFileStamps task to compute all of the stamps for a directory
recursively if an output file is a directory. Prior to that, it had only
computed the stamp for the directory itself. This caused a significant
performance regression in creating the test classloader because it was
computing the last modified time for all of the classfiles in the class path.
The test for 5000 source files in
https://github.com/eatkins/scala-build-watch-performance was running roughly
400ms slower due to this regression.
This commit is contained in:
parent
3f6fa7ee87
commit
ebf6d5aee6
|
|
@ -2041,7 +2041,6 @@ object Classpaths {
|
|||
excludeFilter in unmanagedJars value
|
||||
)
|
||||
).map(exportClasspath) ++ Seq(
|
||||
sbt.nio.Keys.classpathFiles := data(fullClasspath.value).map(_.toPath),
|
||||
sbt.nio.Keys.dependencyClasspathFiles := data(dependencyClasspath.value).map(_.toPath),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,10 @@ private[sbt] object ClassLoaders {
|
|||
*/
|
||||
private[sbt] def testTask: Def.Initialize[Task[ClassLoader]] = Def.task {
|
||||
val si = scalaInstance.value
|
||||
val rawCP = modifiedTimes((outputFileStamps in classpathFiles).value)
|
||||
val cp = fullClasspath.value.map(_.data)
|
||||
val dependencyStamps = modifiedTimes((outputFileStamps in dependencyClasspathFiles).value).toMap
|
||||
def getLm(f: File): Long = dependencyStamps.getOrElse(f, IO.getModifiedTimeOrZero(f))
|
||||
val rawCP = cp.map(f => f -> getLm(f))
|
||||
val fullCP =
|
||||
if (si.isManagedVersion) rawCP
|
||||
else si.libraryJars.map(j => j -> IO.getModifiedTimeOrZero(j)).toSeq ++ rawCP
|
||||
|
|
|
|||
|
|
@ -165,8 +165,6 @@ object Keys {
|
|||
.withRank(Invisible)
|
||||
private[sbt] val dependencyClasspathFiles =
|
||||
taskKey[Seq[Path]]("The dependency classpath for a task.").withRank(Invisible)
|
||||
private[sbt] val classpathFiles =
|
||||
taskKey[Seq[Path]]("The classpath for a task.").withRank(Invisible)
|
||||
private[sbt] val compileOutputs = taskKey[Seq[Path]]("Compilation outputs").withRank(Invisible)
|
||||
private[sbt] val compileSourceFileInputs =
|
||||
taskKey[Map[String, Seq[(Path, FileStamp)]]]("Source file stamps stored by scala version")
|
||||
|
|
|
|||
Loading…
Reference in New Issue