Commit 6a7942c
authored
perf: Swift 6.2 concurrency and performance optimizations (farouqaldori#48)
* refactor(perf): adopt Swift 6.2 concurrency and performance patterns
- Fix ConversationParser actor starvation by extracting file I/O into
nonisolated static methods, preventing actor lock during disk ops
- Add swift-subprocess package for async process execution, replacing
Foundation.Process + DispatchQueue boilerplate in ProcessExecutor
- Optimize HookSocketServer buffer with withUnsafeTemporaryAllocation
for stack allocation instead of per-read heap allocation
- Use lazy split() in incremental parsing to avoid full array allocation
- Move NotchHeaderView animation arrays to static properties
* perf: implement Swift 6.2 performance optimizations
- Cache LCS computation in SimpleDiffView to avoid redundant calculations
- Use space-optimized LCS algorithm with UInt8 direction matrix
- Add ProcessTree struct with O(1) parent→children index for descendant lookup
- Replace components(separatedBy:) with split() for efficient Substring handling
- Add reserveCapacity() calls for predictable array sizes
- Unify ClaudeSessionMonitor Task bridging to reduce executor hops
- Document @Concurrent candidates in ProcessExecutor for Swift 6.2 adoption
* perf: add Swift 6.2 concurrency optimizations
- Enable nonisolated(nonsending) by default via compiler flag
- Enable global concurrency feature for @Concurrent attribute support
- Add @Concurrent to ProcessExecutor async methods for explicit concurrent execution
- Defer String allocation in ConversationParser incremental parsing hot path
* Address review comments from PR farouqaldori#48
- Fix SimpleDiffView computed property recomputation: cachedDiffResult was
a computed property, causing the expensive LCS algorithm to run multiple
times per render pass. Now computed once at the start of body.
- Fix misleading "off-actor" comment in ConversationParser: nonisolated
static methods called synchronously from within an actor still execute
on the actor's executor. Updated documentation to accurately describe
the behavior.
- Fix processIncrementalContent returning all messages on no-op reads:
when there's no new content, the function now returns an empty array
instead of state.messages, which would incorrectly report all messages
as "new" in the IncrementalParseResult.newMessages field.1 parent 778cded commit 6a7942c
9 files changed
Lines changed: 493 additions & 310 deletions
File tree
- ClaudeIsland.xcodeproj
- ClaudeIsland
- Services
- Hooks
- Session
- UI/Views
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| 47 | + | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
| |||
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| 95 | + | |
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
| |||
123 | 126 | | |
124 | 127 | | |
125 | 128 | | |
| 129 | + | |
126 | 130 | | |
127 | 131 | | |
128 | 132 | | |
| |||
305 | 309 | | |
306 | 310 | | |
307 | 311 | | |
308 | | - | |
309 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
310 | 316 | | |
311 | 317 | | |
312 | 318 | | |
| |||
341 | 347 | | |
342 | 348 | | |
343 | 349 | | |
344 | | - | |
345 | 350 | | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
346 | 354 | | |
347 | 355 | | |
348 | 356 | | |
| |||
379 | 387 | | |
380 | 388 | | |
381 | 389 | | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
382 | 398 | | |
383 | 399 | | |
384 | 400 | | |
| |||
403 | 419 | | |
404 | 420 | | |
405 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
406 | 427 | | |
407 | 428 | | |
408 | 429 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
635 | | - | |
636 | 635 | | |
637 | 636 | | |
638 | 637 | | |
639 | | - | |
640 | | - | |
641 | | - | |
642 | | - | |
643 | | - | |
644 | | - | |
645 | | - | |
646 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
647 | 655 | | |
648 | 656 | | |
649 | | - | |
650 | | - | |
651 | | - | |
652 | | - | |
653 | 657 | | |
654 | 658 | | |
655 | 659 | | |
| |||
Lines changed: 43 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 48 | + | |
79 | 49 | | |
80 | 50 | | |
81 | 51 | | |
82 | | - | |
83 | 52 | | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 53 | + | |
92 | 54 | | |
93 | 55 | | |
94 | 56 | | |
| |||
175 | 137 | | |
176 | 138 | | |
177 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
178 | 180 | | |
179 | 181 | | |
180 | 182 | | |
| |||
0 commit comments