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

[Scheduler] Store Tasks on a Min Binary Heap #16245

Merged
merged 2 commits into from Aug 8, 2019

Commits on Aug 8, 2019

  1. [Scheduler] Store Tasks on a Min Binary Heap

    Switches Scheduler's priority queue implementation (for both tasks and
    timers) to an array-based min binary heap.
    
    This replaces the naive linked-list implementation that was left over
    from the queue we once used to schedule React roots. A list was arguably
    fine when it was only used for roots, since the total number of roots is
    usually small, and is only 1 in the common case of a single-page app.
    
    Since Scheduler is now used for many types of JavaScript tasks (e.g.
    including timers), the total number of tasks can be much larger.
    
    Binary heaps are the standard way to implement priority queues.
    Insertion is O(1) in the average case (append to the end) and O(log n)
    in the worst. Deletion is O(log n). Peek is O(1).
    acdlite committed Aug 8, 2019
    Copy the full SHA
    220ba25 View commit details
    Browse the repository at this point in the history
  2. Sophie nits

    acdlite committed Aug 8, 2019
    Copy the full SHA
    f2318c1 View commit details
    Browse the repository at this point in the history