Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
##### Enhancements

- Added support for Bazel 9.x.
- Significant performance improvements. Scanning the Reddit iOS codebase reduced by 80.4% from 77.2s to 15.1s.

##### Bug Fixes

Expand Down
2,762 changes: 2,762 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ var targets: [PackageDescription.Target] = [
name: "SourceGraph",
dependencies: [
.target(name: "Configuration"),
.target(name: "Extensions"),
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SystemPackage", package: "swift-system"),
.target(name: "Shared"),
Expand Down
6 changes: 6 additions & 0 deletions Sources/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,14 @@ swift_library(
"SourceGraph/Elements/DeclarationAttribute.swift",
"SourceGraph/Elements/ImportStatement.swift",
"SourceGraph/Elements/Location.swift",
"SourceGraph/Elements/ModuleBitset.swift",
"SourceGraph/Elements/ModuleID.swift",
"SourceGraph/Elements/ModuleNameInterner.swift",
"SourceGraph/Elements/ProjectFileKind.swift",
"SourceGraph/Elements/Reference.swift",
"SourceGraph/Elements/SourceFile.swift",
"SourceGraph/Elements/USRID.swift",
"SourceGraph/Elements/USRInterner.swift",
"SourceGraph/Mutators/AccessibilityCascader.swift",
"SourceGraph/Mutators/AncestralReferenceEliminator.swift",
"SourceGraph/Mutators/AppIntentsRetainer.swift",
Expand Down Expand Up @@ -98,6 +103,7 @@ swift_library(
module_name = "SourceGraph",
deps = [
"//Sources:Configuration",
"//Sources:Extensions",
"//Sources:Shared",
"@swift-syntax//:SwiftSyntax",
"@swift-system//:SystemPackage",
Expand Down
1 change: 1 addition & 0 deletions Sources/Frontend/Commands/ScanCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ struct ScanCommand: ParsableCommand {

configuration.guidedSetup = setup
configuration.projectRoot = projectRoot

configuration.apply(\.$project, project)
configuration.apply(\.$schemes, schemes)
configuration.apply(\.$indexExclude, indexExclude)
Expand Down
10 changes: 8 additions & 2 deletions Sources/Frontend/Scan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ final class Scan {
self.configuration = configuration
self.logger = logger
self.swiftVersion = swiftVersion
graph = SourceGraph(configuration: configuration, logger: logger)
graph = SourceGraph(configuration: configuration)
}

func perform(project: Project) throws -> [ScanResult] {
Expand All @@ -41,7 +41,11 @@ final class Scan {
try build(driver)
try index(driver)
try analyze()
return buildResults()
let results = buildResults()
// Let the OS reclaim memory at process exit instead of paying
// the cost of tearing down the entire SourceGraph via ARC.
_ = Unmanaged.passRetained(graph)
return results
}

// MARK: - Private
Expand All @@ -68,7 +72,9 @@ final class Scan {
}

let indexLogger = logger.contextualized(with: "index")
let planInterval = logger.beginInterval("index:plan")
let plan = try driver.plan(logger: indexLogger)
logger.endInterval(planInterval)
let graphMutex = SourceGraphMutex(graph: graph)
let pipeline = IndexPipeline(plan: plan, graph: graphMutex, logger: indexLogger, configuration: configuration, swiftVersion: swiftVersion)
try pipeline.perform()
Expand Down
2 changes: 2 additions & 0 deletions Sources/Indexer/IndexPipeline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public struct IndexPipeline {
).perform()
}

let interval = logger.beginInterval("index:complete")
graph.withLock { $0.indexingComplete() }
logger.endInterval(interval)
}
}
6 changes: 3 additions & 3 deletions Sources/Indexer/SourceFileCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public struct SourceFileCollector {
let file = FilePath.makeAbsolute(filePath, relativeTo: currentFilePath)

if !isExcluded(file) {
guard file.exists else {
logger.debug("Source file does not exist: \(file.string)")
if excludedTargets.contains(unit.moduleName) {
return nil
}

if excludedTargets.contains(unit.moduleName) {
guard file.exists else {
logger.debug("Source file does not exist: \(file.string)")
return nil
}

Expand Down
Loading
Loading