Skip to content

Commit 629064c

Browse files
authored
resolve timeout for repositories with large number of tags (#3218)
motivation: in 5.4 we introduced a timeout on computing packages bounds to help mitigate scenarios where the resolution would hang. using a fixed timeout prooves to be incorrect since the time it takes to compute the bounds is a direct function of the number of version the repository has. as such, repositories with very large nuymber of tags (2000+) would hit the timeout changes: make the timeout a function of the # of versions rdar://73470011
1 parent 6cc63ec commit 629064c

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

Sources/PackageGraph/Pubgrub/PubgrubDependencyResolver.swift

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,13 +1251,10 @@ private final class PubGrubPackageContainer {
12511251
}.joined())
12521252
}
12531253

1254-
// FIXME: make timeout configurable
1255-
let computeBoundsTimeout = DispatchTimeInterval.seconds(60)
12561254
let (lowerBounds, upperBounds) = try self.computeBounds(for: node,
12571255
constraints: constraints,
12581256
startingWith: version,
1259-
products: node.productFilter,
1260-
timeout: computeBoundsTimeout)
1257+
products: node.productFilter)
12611258

12621259
return try constraints.map { constraint in
12631260
var terms: OrderedSet<Term> = []
@@ -1293,8 +1290,7 @@ private final class PubGrubPackageContainer {
12931290
for node: DependencyResolutionNode,
12941291
constraints: [PackageContainerConstraint],
12951292
startingWith firstVersion: Version,
1296-
products: ProductFilter,
1297-
timeout: DispatchTimeInterval
1293+
products: ProductFilter
12981294
) throws -> (lowerBounds: [PackageReference: Version], upperBounds: [PackageReference: Version]) {
12991295
let preloadCount = 3
13001296

@@ -1312,8 +1308,7 @@ private final class PubGrubPackageContainer {
13121308
}
13131309
}
13141310
}
1315-
// not throwing here since its only an optimization
1316-
_ = sync.wait(timeout: .now() + timeout)
1311+
sync.wait()
13171312
}
13181313

13191314
func compute(_ versions: [Version], upperBound: Bool) -> [PackageReference: Version] {
@@ -1379,8 +1374,10 @@ private final class PubGrubPackageContainer {
13791374
lowerBounds = compute(Array(versions.dropLast(versions.count - idx).reversed()), upperBound: false)
13801375
}
13811376

1377+
// timeout is a function of # of versions since we need to make several git operations per tag/version
1378+
let timeout = DispatchTimeInterval.seconds(60 + versions.count)
13821379
guard case .success = sync.wait(timeout: .now() + timeout) else {
1383-
throw StringError("timeout computing \(node.package.name) bounds")
1380+
throw StringError("timeout computing '\(node.package.name)' bounds")
13841381
}
13851382

13861383
return (lowerBounds, upperBounds)

Sources/SourceControl/GitRepository.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ private struct GitShellHelper {
2727
/// Private function to invoke the Git tool with its default environment and given set of arguments. The specified
2828
/// failure message is used only in case of error. This function waits for the invocation to finish and returns the
2929
/// output as a string.
30-
func run(_ args: [String], environment: [String: String] = Git.environment) throws -> String
31-
{
30+
func run(_ args: [String], environment: [String: String] = Git.environment) throws -> String {
3231
let process = Process(arguments: [Git.tool] + args, environment: environment, outputRedirection: .collect)
3332
let result: ProcessResult
3433
do {

0 commit comments

Comments
 (0)