⚡ Bolt: Replace actors with structs for truly parallel file scanning#56
⚡ Bolt: Replace actors with structs for truly parallel file scanning#56
Conversation
In Swift's structured concurrency, using `actor` to isolate a `withTaskGroup` inadvertently serializes its child tasks if they inherit the actor context. Since `CacheScanner` and `NodeModulesScanner` only rely on thread-safe dependencies (`FileManager`), converting them to `struct`s prevents this serialization and allows parallel file-system scanning as originally intended. Co-authored-by: acebytes <2820910+acebytes@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: Replaced
actorwithstructforCacheScannerandNodeModulesScanner.🎯 Why: In Swift's structured concurrency, running
withTaskGroupinside anactorcauses its child tasks to inherit the actor's isolation context. When tasks invoke synchronous blocking I/O (likeFileManager), this inadvertently serializes execution and prevents actual parallelism. Changing these stateless components tostructs lets the tasks execute concurrently on the global executor.📊 Impact: Significantly improves parallel scanning speed for both
node_modulesand generic cache folders by unlocking true concurrent background execution.🔬 Measurement: Compare scan completion times before and after for heavy
node_modulesfolders. Also, added a note to.jules/bolt.mdreflecting this specific Swift concurrency pitfall.PR created automatically by Jules for task 3269976156032958516 started by @acebytes