Conversation
3e19ea4 to
a7db8be
Compare
36eb67c to
eb64ee8
Compare
There was a problem hiding this comment.
Pull request overview
This PR focuses on performance optimizations across indexing and graph mutation by reducing hashing/string work (interning, ordinal hashing, cached lookups) and avoiding redundant SwiftSyntax traversals.
Changes:
- Introduces USR/module interning and replaces several hot-path
String/Dictionarylookups with integer IDs + array/bitset indexing. - Optimizes indexing/mutation passes (batch additions, capacity reservation, fewer Set rebuilds, reduced syntax traversal).
- Refactors/updates tests and Bazel baselines to align with the new symbols and data flow.
Reviewed changes
Copilot reviewed 48 out of 49 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| baselines/linux-bazel.json | Updates baseline symbols for new UnusedParameterParser.parse overloads. |
| baselines/bazel.json | Updates baseline symbols for new UnusedParameterParser.parse overloads. |
| Tests/Shared/SourceGraphTestCase.swift | Switches “used” assertion to Declaration.isUsed. |
| Tests/PeripheryTests/ObjcAnnotatedRetentionTest.swift | Makes @testable import TestShared conditional for macOS. |
| Tests/PeripheryTests/ObjcAccessibleRetentionTest.swift | Makes @testable import TestShared conditional for macOS. |
| Tests/PeripheryTests/DeterminismRegressionTest.swift | Updates fixtures for usrID/indexing changes and adds indexingComplete() where required. |
| Sources/SyntaxAnalysis/UnusedParameterParser.swift | Adds node-based parsing entrypoint + reduces traversal work; interns parameter USRs. |
| Sources/SyntaxAnalysis/UnusedParameterAnalyzer.swift | Adds an overload that consumes pre-collected function/initializer nodes. |
| Sources/SyntaxAnalysis/FunctionCollectorVisitor.swift | New visitor to collect function/initializer nodes during multiplexed traversal. |
| Sources/SyntaxAnalysis/DeclarationSyntaxVisitor.swift | Replaces tuple result with reference type + maintains resultsByLocation incrementally. |
| Sources/SourceGraph/SourceGraphMutex.swift | Exposes thread-safe usrInterner and adds reserveCapacity(forFileCount:). |
| Sources/SourceGraph/SourceGraph.swift | Large hot-path rewrite: USR/module interning, reference buckets by USRID, caching, capacity reservation. |
| Sources/SourceGraph/Mutators/UsedDeclarationMarker.swift | Marks usage via isUsed flag and refactors traversal logic. |
| Sources/SourceGraph/Mutators/UnusedParameterRetainer.swift | Switches declaration lookup to usrID-based API. |
| Sources/SourceGraph/Mutators/UnusedImportMarker.swift | Reworks unused-import detection using module bitsets and caches. |
| Sources/SourceGraph/Mutators/StructImplicitInitializerReferenceBuilder.swift | Switches to usrID flow and avoids repeated string hashing. |
| Sources/SourceGraph/Mutators/RedundantProtocolMarker.swift | Switches declaration lookup to usrID-based API. |
| Sources/SourceGraph/Mutators/RedundantExplicitPublicAccessibilityMarker.swift | Switches declaration lookup to usrID-based API. |
| Sources/SourceGraph/Mutators/ProtocolExtensionReferenceBuilder.swift | Switches to usrID flow and reduces repeated set membership costs. |
| Sources/SourceGraph/Mutators/ProtocolConformanceReferenceBuilder.swift | Optimizes reference inversion and switches to usrID flow + batch capacity reservation. |
| Sources/SourceGraph/Mutators/InheritedImplicitInitializerReferenceBuilder.swift | Switches to usrID flow when resolving implicit/explicit inits. |
| Sources/SourceGraph/Mutators/GenericClassAndStructConstructorReferenceBuilder.swift | Switches to usrID flow when building constructor refs. |
| Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift | Switches to usrID lookups for protocol/member resolution. |
| Sources/SourceGraph/Mutators/ExternalOverrideRetainer.swift | Switches to usrID-based external-match detection. |
| Sources/SourceGraph/Mutators/ExtensionReferenceBuilder.swift | Switches extension folding lookup to usrID API. |
| Sources/SourceGraph/Mutators/EnumCaseReferenceBuilder.swift | Switches to usrID flow for enum-case references. |
| Sources/SourceGraph/Mutators/DefaultConstructorReferenceBuilder.swift | Switches to usrID flow for ctor/dtor references. |
| Sources/SourceGraph/Mutators/ComplexPropertyAccessorReferenceBuilder.swift | Switches to usrID flow for accessor references. |
| Sources/SourceGraph/Mutators/CodingKeyEnumReferenceBuilder.swift | Switches to usrID flow for Codable CodingKey refs. |
| Sources/SourceGraph/Mutators/AssignOnlyPropertyReferenceEliminator.swift | Refactors retained-type computation to avoid recomputing sanitized lists. |
| Sources/SourceGraph/Mutators/AssetReferenceRetainer.swift | Replaces descendant set construction with iterative traversal helper. |
| Sources/SourceGraph/Mutators/AncestralReferenceEliminator.swift | Replaces hashed Set ancestor stack with linear array of USRIDs. |
| Sources/SourceGraph/Elements/USRInterner.swift | New thread-safe USR interner (String <-> USRID). |
| Sources/SourceGraph/Elements/SourceFile.swift | Caches hash work for SourceFile keys. |
| Sources/SourceGraph/Elements/Reference.swift | Adds usrID and switches hashing/equality to ordinal/int-based keys. |
| Sources/SourceGraph/Elements/ModuleNameInterner.swift | New module-name interner for ModuleID usage. |
| Sources/SourceGraph/Elements/ModuleID.swift | Adds ModuleID, ModuleBitset, and USRID lightweight integer handles. |
| Sources/SourceGraph/Elements/Location.swift | Converts Location to a value type and changes hashing/description caching behavior. |
| Sources/SourceGraph/Elements/Declaration.swift | Adds usrIDs, isUsed, ordinal hashing for Kind, and faster override detection. |
| Sources/Shared/PropertyTypeSanitizer.swift | Avoids rebuilding CharacterSet each call. |
| Sources/PeripheryKit/ScanResultBuilder.swift | Uses isUsed, uses descendant traversal helper, and interns ignored-parameter USRs. |
| Sources/PeripheryKit/Results/OutputDeclarationFilter.swift | Avoids building intermediate ignored-USR sets and caches include/exclude matcher results. |
| Sources/Indexer/SwiftIndexer.swift | Reserves graph capacity, batches reference addition, interns USRs, avoids extra sorting/traversal work. |
| Sources/Indexer/IndexPipeline.swift | Adds timing interval around indexingComplete(). |
| Sources/Frontend/Scan.swift | Intentionally retains the graph to avoid ARC teardown costs at exit. |
| Sources/Frontend/Commands/ScanCommand.swift | Removes assignment to now-removed Configuration.projectRoot. |
| Sources/Configuration/Configuration.swift | Removes projectRoot from configuration. |
| Sources/BUILD.bazel | Adds new SourceGraph/SyntaxAnalysis sources to Bazel build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sources/SourceGraph/Mutators/ExternalTypeProtocolConformanceReferenceRemover.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 49 out of 50 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
Sources/SourceGraph/Elements/Location.swift:29
Location.relativeTo(_:)creates a newSourceFileand copiesimportStatements, but it does not copyimportsSwiftTesting. This can leave the derived flag inconsistent with the copied imports for the returnedLocation’sfile. Consider also copyingimportsSwiftTesting(or computing it from the copied import statements) so the newSourceFilepreserves the original file metadata consistently.
func relativeTo(_ path: FilePath) -> Location {
let newPath = file.path.relativeTo(path)
let newFile = SourceFile(path: newPath, modules: file.modules)
newFile.importStatements = file.importStatements
return Location(file: newFile, line: line, column: column)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
eb11202 to
40684b8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 54 out of 55 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
14ef862 to
a7cbee0
Compare
642f73f to
87d1851
Compare
No description provided.