Skip to content

[5.9][🍒][Dependency Scanning] Remove coarse-grained synchronization on all dependency scan queries #1327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ public class InterModuleDependencyOracle {
commandLine: [String])
throws -> InterModuleDependencyGraph {
precondition(hasScannerInstance)
return try queue.sync {
return try swiftScanLibInstance!.scanDependencies(workingDirectory: workingDirectory,
moduleAliases: moduleAliases,
invocationCommand: commandLine)
}
return try swiftScanLibInstance!.scanDependencies(workingDirectory: workingDirectory,
moduleAliases: moduleAliases,
invocationCommand: commandLine)
}

@_spi(Testing) public func getBatchDependencies(workingDirectory: AbsolutePath,
Expand All @@ -60,24 +58,20 @@ public class InterModuleDependencyOracle {
batchInfos: [BatchScanModuleInfo])
throws -> [ModuleDependencyId: [InterModuleDependencyGraph]] {
precondition(hasScannerInstance)
return try queue.sync {
return try swiftScanLibInstance!.batchScanDependencies(workingDirectory: workingDirectory,
moduleAliases: moduleAliases,
invocationCommand: commandLine,
batchInfos: batchInfos)
}
return try swiftScanLibInstance!.batchScanDependencies(workingDirectory: workingDirectory,
moduleAliases: moduleAliases,
invocationCommand: commandLine,
batchInfos: batchInfos)
}

@_spi(Testing) public func getImports(workingDirectory: AbsolutePath,
moduleAliases: [String: String]? = nil,
commandLine: [String])
throws -> InterModuleDependencyImports {
precondition(hasScannerInstance)
return try queue.sync {
return try swiftScanLibInstance!.preScanImports(workingDirectory: workingDirectory,
moduleAliases: moduleAliases,
invocationCommand: commandLine)
}
return try swiftScanLibInstance!.preScanImports(workingDirectory: workingDirectory,
moduleAliases: moduleAliases,
invocationCommand: commandLine)
}

/// Given a specified toolchain path, locate and instantiate an instance of the SwiftScan library
Expand Down
9 changes: 4 additions & 5 deletions Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,6 @@ final class ExplicitModuleBuildTests: XCTestCase {
"-I", stdLibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-F", frameworksPath.nativePathString(escaped: true),
"-import-objc-header",
"-explicit-module-build",
"-module-name", "main",
"-working-directory", path.nativePathString(escaped: true),
Expand Down Expand Up @@ -1193,7 +1192,6 @@ final class ExplicitModuleBuildTests: XCTestCase {
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-import-objc-header",
"-explicit-module-build",
"-working-directory", path.nativePathString(escaped: true),
"-disable-clang-target",
Expand Down Expand Up @@ -1265,7 +1263,6 @@ final class ExplicitModuleBuildTests: XCTestCase {
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"/tmp/Foo.o",
"-import-objc-header",
"-explicit-module-build",
"-working-directory", path.nativePathString(escaped: true),
"-disable-clang-target",
Expand Down Expand Up @@ -1303,7 +1300,10 @@ final class ExplicitModuleBuildTests: XCTestCase {
DispatchQueue.concurrentPerform(iterations: 20) { index in
// Give the main modules different names
let iterationCommand = scannerCommand + ["-module-name",
"testDependencyScanning\(index)"]
"testDependencyScanning\(index)",
// FIXME: We need to differentiate the scanning action hash,
// though the module-name above should be sufficient.
"-I/tmp/foo/bar/\(index)"]
let dependencyGraph =
try! dependencyOracle.getDependencies(workingDirectory: path,
commandLine: iterationCommand)
Expand Down Expand Up @@ -1458,7 +1458,6 @@ final class ExplicitModuleBuildTests: XCTestCase {
"-I", swiftModuleInterfacesPath.nativePathString(escaped: true),
"-I", stdlibPath.nativePathString(escaped: true),
"-I", shimsPath.nativePathString(escaped: true),
"-import-objc-header",
"-explicit-module-build",
"-working-directory", path.nativePathString(escaped: true),
"-disable-clang-target",
Expand Down