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

[Fiber] Separate priority for updates #8538

Merged
merged 16 commits into from
Dec 16, 2016
Merged

Commits on Dec 15, 2016

  1. Don't drop updates until they are committed

    Restructures the update queue to maintain a pointer to the first
    pending update, which solves a few problems:
    
    - Updates that occur during the begin phase (e.g. in cWRP of a child)
    aren't dropped, like they are currently. This isn't working yet because
    the work priority is reset during completion. The following item will
    fix it.
    - Sets us up to be able to add separate priorities to each update in
    the queue. I'll add this in a subsequent commit.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    cbba5ef View commit details
    Browse the repository at this point in the history
  2. Schedule callback effects while merging updates

    This allows us to remove the hasCallback flag.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    6301086 View commit details
    Browse the repository at this point in the history
  3. Replace .hasForceUpdate with ForceUpdate effect

    Removes another field from the update queue
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    cb1ef03 View commit details
    Browse the repository at this point in the history
  4. Separate priority for updates

    When resetting the priority in the complete phase, check the priority of
    the update queue so that updates aren't dropped.
    
    Updates inside render, child cWRP, etc are no longer dropped.
    
    The next step is sort the queue by priority and only flush updates that
    match the current priority level.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    94011e9 View commit details
    Browse the repository at this point in the history
  5. Use lastProgressedUpdate pointer instead of firstPendingUpdate

    We need to be able to access both, and since the list uses forward
    pointers, it makes more sense to point to the one that comes first.
    Otherwise to get the last progressed update you have to start at the
    beginning of the list.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    bb844a0 View commit details
    Browse the repository at this point in the history
  6. Apply pending updates in order of priority

    The queue maintains a pointer to the last progressed update in the list.
    Updates that come after that pointer are pending. The pointer is set to
    the end of the list during reconciliation.
    
    Pending updates are sorted by priority then insertion. Progressed
    updates are sorted by the order in which they were applied during
    reconciliation, which may not be by priority: if a component bails out
    before the updates are committed, in the next render, the progressed
    updates are applied in the same order that they were previously, even if
    a higher priority update comes in.
    
    Once a progressed update is flushed/committed, it's removed from
    the queue.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    20f0004 View commit details
    Browse the repository at this point in the history
  7. Add unstable_deferredUpdates

    This is needed to get the triangle demo working.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    ead8ab7 View commit details
    Browse the repository at this point in the history
  8. Don't rely on commit phase effect to clear updates

    Instead clear updates on the work-in-progress during the begin phase.
    Aborted updates are recovered by cloning from the current fiber.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    d7f89b8 View commit details
    Browse the repository at this point in the history
  9. Add fast path for appending updates to the end of the queue

    This is the most common case, so we should avoid scanning the entire
    list to get to the end.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    babace0 View commit details
    Browse the repository at this point in the history
  10. Handle setState inside an updater function

    The update is scheduled as if the current processing update has already
    been processed; if it has the same or higher priority, it will be
    flushed in the same batch.
    
    We also print a warning.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    e0981b8 View commit details
    Browse the repository at this point in the history
  11. Priority context during reconciliation

    setState inside render/cWRP should have the same priority as whatever
    level is currently being reconciled.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    eec4312 View commit details
    Browse the repository at this point in the history
  12. Simplify test for whether we should flush a pending commit

    We can just check if the deadline has expired.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    df9603e View commit details
    Browse the repository at this point in the history
  13. Move priority context change to findNextUnitOfWork

    ...rather than changing it on every unit of work.
    acdlite committed Dec 15, 2016
    Configuration menu
    Copy the full SHA
    e1b733f View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    496512f View commit details
    Browse the repository at this point in the history
  15. Use 255 instead of infinity

    Infinity is a floating point value.
    acdlite committed Dec 15, 2016
    3 Configuration menu
    Copy the full SHA
    3a946fe View commit details
    Browse the repository at this point in the history

Commits on Dec 16, 2016

  1. Remove ForceUpdate effect

    Go back to using a flag, instead. I removed it before because I thought
    we might want to get rid of the top-level UpdateQueue type and put
    the fields directly on the fiber, but since we're keeping UpdateQueue
    we can put hasForceUpdate on there.
    acdlite committed Dec 16, 2016
    Configuration menu
    Copy the full SHA
    b8441ba View commit details
    Browse the repository at this point in the history