Files
Alex Hoppen 44a095c8aa Use an AtomicInt32 to count pendingUnitCount instead of using AsyncQueue
Adding an item to `AsyncQueue<Serial>` is linear in the number of pending queue items, thus adding n items to an `AsyncQueue` before any can execute is in O(n^2). This decision was made intentionally because the primary use case for `AsyncQueue` was to track pending LSP requests, of which we don’t expect to have too many pending requests at any given time.

`SourceKitIndexDelegate` was also using `AsyncQueue` to track the number of pending units to be processed and eg. after indexing SourceKit-LSP, I have seen this grow up to ~20,000. With the quadratic behavior, this explodes time-wise.

Turns out that we don’t actually need to use a queue here at all, an atomic is sufficient and much faster.

Independently, we should consider mitigating the quadratic behavior of `AsyncQueue<Serial>` or `AsyncQueue` in general.

Fixes #1541
rdar://130844901
2024-10-08 17:35:13 -07:00
..
2024-06-04 07:06:44 -07:00