Skip to content

Releases: michaelversus/SwiftFindRefs

1.0.4

Choose a tag to compare

@github-actions github-actions released this 29 Jan 22:12

What's Changed

  • Fix --derivedDataPath not working properly and renaming CLI option to --dataStorePath by @Nikoloutsos in #9

Full Changelog: 1.0.3...1.0.4

1.0.3

Choose a tag to compare

@github-actions github-actions released this 29 Jan 07:02

What's Changed

Full Changelog: 1.0.2...1.0.3

1.0.2

Choose a tag to compare

@github-actions github-actions released this 28 Jan 22:18

What's Changed

New Contributors

Full Changelog: 1.0.1...1.0.2

1.0.1

Choose a tag to compare

@github-actions github-actions released this 16 Jan 08:12

What's Changed

Full Changelog: 1.0.0...1.0.1

1.0.0

Choose a tag to compare

@github-actions github-actions released this 16 Jan 06:32

What's Changed

Full Changelog: 0.2.5...1.0.0

0.2.5

Choose a tag to compare

@github-actions github-actions released this 14 Jan 20:34

What's Changed

Full Changelog: 0.2.4...0.2.5

0.2.4

Choose a tag to compare

@michaelversus michaelversus released this 14 Jan 14:54

Minor fixes

0.2.3

Choose a tag to compare

@michaelversus michaelversus released this 14 Jan 14:17
9fa32dc

Adds an OpenSkills-compatible agent skill (swiftfindrefs/) to teach AI coding agents to use IndexStore-based reference discovery via swiftfindrefs instead of text search.

Thanks @ezefranca ❤️

0.2.2

Choose a tag to compare

@michaelversus michaelversus released this 14 Jan 01:45
6355d8e

Migrate to Swift Concurrency with Structured Concurrency

Overview

This MR migrates SwiftFindRefs from legacy GCD (DispatchQueue.concurrentPerform) to modern Swift Concurrency using structured concurrency (withTaskGroup). The migration improves code quality, type safety, and maintainability while maintaining equivalent performance.

🎯 Key Changes

Core Implementation

  • Replaced DispatchQueue.concurrentPerform with withTaskGroup

    • Migrated from GCD-based parallel execution to Swift Concurrency task groups
    • Eliminated manual thread synchronization code
  • Removed ThreadSafeSet with NSLock

    • Replaced manual locking mechanism with Swift's built-in structured concurrency
    • Removed @unchecked Sendable annotation and manual lock management
    • Reduced code complexity by ~15 lines
  • Made APIs async/await

    • IndexStoreFinder.fileReferences() methods are now async throws
    • CompositionRoot.run() is now async throws
    • Updated to AsyncParsableCommand for native async support

Test Updates

  • Updated all test methods to use async/await patterns
  • Added Sendable conformance to mock types for thread safety

📊 Performance

Benchmark Results

Test Configuration:

  • Project: Large
  • Symbol: Some (class)
  • References Found: 136 files

Performance Comparison:

  • Old (GCD): ~3.6-3.8 seconds, 134-169% CPU usage
  • New (Swift Concurrency): ~3.3-4.6 seconds, 131-165% CPU usage
  • Result: ✅ Equivalent performance with no regression

Key Metrics

  • Correctness: Identical results (136 references)
  • Performance: Equivalent execution times
  • CPU Utilization: Effective multi-core usage (130-175%)
  • Stability: Consistent performance across multiple runs

🔧 Technical Details

Before (GCD)

DispatchQueue.concurrentPerform(iterations: index.recordNames.count) { i in
    let recordName = index.recordNames[i]
    if recordContainsSymbol(store: store, recordName: recordName, query: query) {
        let filename = index.sourcePath(for: recordName)
        referencedFiles.insert(filename) // Manual lock required
    }
}

After (Swift Concurrency)

await withTaskGroup(of: String?.self) { group in
    for recordName in index.recordNames {
        group.addTask {
            guard recordContainsSymbol(store: store, recordName: recordName, query: query) else {
                return nil
            }
            return index.sourcePath(for: recordName)
        }
    }
    // Automatic synchronization, no locks needed
}

✨ Benefits

  1. Structured Concurrency

    • Automatic task management and cancellation
    • Better error handling and propagation
    • No manual synchronization required
  2. Type Safety

    • Compile-time guarantees with Sendable conformance
    • Eliminated @unchecked Sendable annotations
    • Better isolation checking
  3. Code Quality

    • Cleaner, more maintainable code
    • Reduced complexity (~15 lines removed)
    • Modern Swift 6.2 patterns
  4. Future-Proof

    • Ready for Swift 6 strict concurrency checking
    • Aligned with Apple's recommended concurrency patterns
    • Better integration with async/await ecosystem

🧪 Testing

  • ✅ All 54 tests passing
  • ✅ Benchmark verification completed
  • ✅ Result correctness verified (identical output)
  • ✅ Performance regression testing passed

🔍 Migration Strategy

This migration follows Swift Concurrency best practices:

  1. ✅ Replaced GCD with structured concurrency
  2. ✅ Removed manual synchronization primitives
  3. ✅ Added proper Sendable conformance
  4. ✅ Maintained backward compatibility (same results)
  5. ✅ Verified performance equivalence

📚 References

0.2.1

Choose a tag to compare

@michaelversus michaelversus released this 14 Jan 00:18
54f5ed5

Architecture Improvements and Testability