Skip to content

Commit fa2ceac

Browse files
committed
[Commands] Remove build manifest caching
<rdar://problem/42583418> Remove build manifest caching The build manifest caching provides a preformance win but creating build plan is now faster (than build manifest caching) because of package manifest caching. The difference is about 100ms and we can bring the time down by optimizing the tools lookup. However, this feature is not critical anymore because the performance is decent with package manifest caching. We can add it back in the future when required. 
1 parent 2b579c4 commit fa2ceac

File tree

4 files changed

+3
-70
lines changed

4 files changed

+3
-70
lines changed

Sources/Commands/SwiftBuildTool.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,9 @@ public class SwiftBuildTool: SwiftTool<BuildToolOptions> {
5353

5454
guard let subset = options.buildSubset(diagnostics: diagnostics) else { return }
5555

56-
// Check if we need to generate the llbuild manifest.
57-
let regenerateManifest = try shouldRegenerateManifest()
58-
if regenerateManifest {
59-
// Create the build plan and build normally.
60-
let plan = try BuildPlan(buildParameters: buildParameters(), graph: loadPackageGraph(), diagnostics: diagnostics)
61-
try build(plan: plan, subset: subset)
62-
} else {
63-
// Otherwise, run llbuild directly.
64-
try build(parameters: buildParameters(), subset: subset)
65-
}
56+
// Create the build plan and build.
57+
let plan = try BuildPlan(buildParameters: buildParameters(), graph: loadPackageGraph(), diagnostics: diagnostics)
58+
try build(plan: plan, subset: subset)
6659

6760
case .binPath:
6861
try print(buildParameters().buildPath.asString)

Sources/Commands/SwiftTool.swift

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,6 @@ public class SwiftTool<Options: ToolOptions> {
374374
usage: "Link Swift stdlib statically"),
375375
to: { $0.shouldLinkStaticSwiftStdlib = $1 })
376376

377-
binder.bind(
378-
option: parser.add(option: "--enable-build-manifest-caching", kind: Bool.self,
379-
usage: "Enable llbuild manifest caching [Experimental]"),
380-
to: { $0.shouldEnableManifestCaching = $1 })
381-
382377
// Let subclasses bind arguments.
383378
type(of: self).defineArguments(parser: parser, binder: binder)
384379

@@ -539,13 +534,10 @@ public class SwiftTool<Options: ToolOptions> {
539534
// Throw if there were errors when loading the graph.
540535
// The actual errors will be printed before exiting.
541536
guard !diagnostics.hasErrors else {
542-
try buildManifestRegenerationToken().set(valid: false)
543537
throw Diagnostics.fatalError
544538
}
545-
try buildManifestRegenerationToken().set(valid: true)
546539
return graph
547540
} catch {
548-
try buildManifestRegenerationToken().set(valid: false)
549541
throw error
550542
}
551543
}
@@ -559,30 +551,6 @@ public class SwiftTool<Options: ToolOptions> {
559551
return try _manifestLoader.dematerialize()
560552
}
561553

562-
func shouldRegenerateManifest() throws -> Bool {
563-
// Check if we are allowed to use llbuild manifest caching.
564-
guard options.shouldEnableManifestCaching else {
565-
return true
566-
}
567-
568-
// Check if we need to generate the llbuild manifest.
569-
let parameters: BuildParameters = try self.buildParameters()
570-
guard localFileSystem.isFile(parameters.llbuildManifest) else {
571-
return true
572-
}
573-
574-
// Run the target which computes if regeneration is needed.
575-
let args = [try getToolchain().llbuild.asString, "-f", parameters.llbuildManifest.asString, "regenerate"]
576-
do {
577-
try Process.checkNonZeroExit(arguments: args)
578-
} catch {
579-
// Regenerate the manifest if this fails for some reason.
580-
warning(message: "Failed to run the regeneration check: \(error)")
581-
return true
582-
}
583-
return try !self.buildManifestRegenerationToken().isValid()
584-
}
585-
586554
func computeLLBuildTargetName(for subset: BuildSubset) throws -> String? {
587555
switch subset {
588556
case .allExcludingTests:
@@ -711,7 +679,6 @@ public class SwiftTool<Options: ToolOptions> {
711679
destinationTriple: triple,
712680
flags: options.buildFlags,
713681
shouldLinkStaticSwiftStdlib: options.shouldLinkStaticSwiftStdlib,
714-
shouldEnableManifestCaching: options.shouldEnableManifestCaching,
715682
sanitizers: options.sanitizers
716683
)
717684
})

Tests/CommandsTests/BuildToolTests.swift

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -177,30 +177,4 @@ final class BuildToolTests: XCTestCase {
177177
}
178178
}
179179
}
180-
181-
func testLLBuildManifestCachingBasics() {
182-
fixture(name: "ValidLayouts/SingleModule/ExecutableNew") { path in
183-
let fs = localFileSystem
184-
185-
// First run should produce output.
186-
var output = try execute(["--enable-build-manifest-caching"], packagePath: path)
187-
XCTAssert(!output.isEmpty, output)
188-
189-
// Null builds.
190-
output = try execute(["--enable-build-manifest-caching"], packagePath: path)
191-
XCTAssert(output.isEmpty, output)
192-
193-
output = try execute(["--enable-build-manifest-caching"], packagePath: path)
194-
XCTAssert(output.isEmpty, output)
195-
196-
// Adding a new file should reset the token.
197-
try fs.writeFileContents(path.appending(components: "Sources", "ExecutableNew", "bar.swift"), bytes: "")
198-
output = try execute(["--enable-build-manifest-caching"], packagePath: path)
199-
XCTAssert(!output.isEmpty, output)
200-
201-
// This should be another null build.
202-
output = try execute(["--enable-build-manifest-caching"], packagePath: path)
203-
XCTAssert(output.isEmpty, output)
204-
}
205-
}
206180
}

Tests/CommandsTests/XCTestManifests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import XCTest
44
extension BuildToolTests {
55
static let __allTests = [
66
("testBinPathAndSymlink", testBinPathAndSymlink),
7-
("testLLBuildManifestCachingBasics", testLLBuildManifestCachingBasics),
87
("testNonReachableProductsAndTargetsFunctional", testNonReachableProductsAndTargetsFunctional),
98
("testProductAndTarget", testProductAndTarget),
109
("testSeeAlso", testSeeAlso),

0 commit comments

Comments
 (0)