Skip to content

Commit

Permalink
Merge pull request #2115 from sbt/wip/caller
Browse files Browse the repository at this point in the history
Fixes #2105/#1763. Cached resolution: removes duplicate callers during merge
  • Loading branch information
jsuereth committed Jul 18, 2015
2 parents 9b71415 + 7eb7df0 commit e6f8d66
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private[sbt] object CachedResolutionResolveCache {
def createID(organization: String, name: String, revision: String) =
ModuleRevisionId.newInstance(organization, name, revision)
def sbtOrgTemp = JsonUtil.sbtOrgTemp
def graphVersion = "0.13.9B"
def graphVersion = "0.13.9C"
val buildStartup: Long = System.currentTimeMillis
lazy val todayStr: String = toYyyymmdd(buildStartup)
lazy val tomorrowStr: String = toYyyymmdd(buildStartup + (1 day).toMillis)
Expand Down Expand Up @@ -470,8 +470,10 @@ private[sbt] trait CachedResolutionResolveEngine extends ResolveEngine {
def mergeModuleReports(org: String, name: String, version: String, xs: Seq[ModuleReport]): ModuleReport = {
val completelyEvicted = xs forall { _.evicted }
val allCallers = xs flatMap { _.callers }
// Caller info is often repeated across the subprojects. We only need ModuleID info for later, so xs.head is ok.
val distinctByModuleId = allCallers.groupBy({ _.caller }).toList map { case (k, xs) => xs.head }
val allArtifacts = (xs flatMap { _.artifacts }).distinct
xs.head.copy(artifacts = allArtifacts, evicted = completelyEvicted, callers = allCallers)
xs.head.copy(artifacts = allArtifacts, evicted = completelyEvicted, callers = distinctByModuleId)
}
val merged = (modules groupBy { m => (m.module.organization, m.module.name, m.module.revision) }).toSeq.toVector flatMap {
case ((org, name, version), xs) =>
Expand Down
5 changes: 5 additions & 0 deletions ivy/src/test/scala/BaseIvySpecification.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ trait BaseIvySpecification extends Specification {
IvyActions.updateEither(module, config, UnresolvedWarningConfiguration(), LogicalClock.unknown, Some(currentDependency), log)
}

def cleanIvyCache: Unit =
{
IO.delete(currentTarget / "cache")
}

def cleanCachedResolutionCache(module: IvySbt#Module): Unit =
{
IvyActions.cleanCachedResolutionCache(module, log)
Expand Down
4 changes: 3 additions & 1 deletion ivy/src/test/scala/CachedResolutionSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class CachedResolutionSpec extends BaseIvySpecification {
import ShowLines._

def e1 = {
cleanIvyCache
val m = module(ModuleID("com.example", "foo", "0.1.0", Some("compile")),
Seq(commonsIo13), Some("2.10.2"), UpdateOptions().withCachedResolution(true))
val report = ivyUpdate(m)
Expand Down Expand Up @@ -65,7 +66,8 @@ class CachedResolutionSpec extends BaseIvySpecification {
// avro:1.4.0 will be evicted by avro:1.7.7.
// #2046 says that netty:3.2.0.Final is incorrectly evicted by netty:3.2.1.Final
def e3 = {
log.setLevel(Level.Debug)
// log.setLevel(Level.Debug)
cleanIvyCache
val m = module(ModuleID("com.example", "foo", "0.3.0", Some("compile")),
Seq(avro177, dataAvro1940, netty320),
Some("2.10.2"), UpdateOptions().withCachedResolution(true))
Expand Down
2 changes: 1 addition & 1 deletion notes/0.13.9.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ On a larger dependency graph, the JSON file growing to be 100MB+
with 97% of taken up by *caller* information.
To make the matter worse, these large JSON files were never cleaned up.

sbt 0.13.9 filters out artificial callers,
sbt 0.13.9 filters out artificial or duplicate callers,
which fixes `OutOfMemoryException` seen on some builds.
This generally shrinks the size of JSON, so it should make the IO operations faster.
Dynamic graphs will be rotated with directories named after `yyyy-mm-dd`,
Expand Down

0 comments on commit e6f8d66

Please sign in to comment.