Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix quadratic performance issue in AsyncQueue<Serial> #1840

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Nov 22, 2024

  1. Fix quadratic performance issue in AsyncQueue<Serial>

    Adding an item to `AsyncQueue` was 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.
    
    While we can't fix the quadratic performance issue in general, we can resolve the quadratic issue of `AsyncQueue<Serial>` by making a new task only depend on the last item in the queue, which then transitively depends on all the previous items. `AsyncQueue<Serial>` are the queues that are most likely to contain many items.
    
    Fixes swiftlang#1725
    rdar://137886469
    ahoppen committed Nov 22, 2024
    Configuration menu
    Copy the full SHA
    eb982d5 View commit details
    Browse the repository at this point in the history