Framework InternalsBaseline · Widely

Priority Lanes & Time-Slicing Schedulers

Mental Model

Synchronous Virtual DOM diffing blocks input events until the entire tree finishes. Concurrent schedulers assign 31-bit priority lanes to updates, slicing work into 5 ms chunks and calling Scheduler Yield primitives so urgent keystrokes preempt background renders.

Interactive Simulator

Priority Lanes & Time-Slicing

Trace how a 5 ms time-sliced render yields to an urgent keystroke and resumes.

SyncLane: Empty
TransitionLane: 420/2000
Main Thread: 5 ms
Step 1 / 3: 1. Schedule TransitionLane Work

Filtering 2,000 rows assigns TransitionLane (0b1000000) and starts a 5 ms slice.

startTransition(() => setFilter(query));
Internal State / Memory
activeLane
TransitionLane
fibersProcessed
420
sliceMs
5

Under the Hood

Frameworks represent update priorities as a 31-bit integer bitmask (SyncLane = 1, InputContinuousLane = 4, TransitionLane = 64), enabling O(1) bitwise scheduling checks.

  1. Lane Bitmasking: When setState fires inside startTransition, the scheduler ORs a TransitionLane bit onto the fiber's lanes field and bubbles childLanes up to the root.
  2. Work Loop & 5 ms Slice: During workLoopConcurrent(), the runtime processes one fiber node at a time and checks performance.now() >= deadline (typically 5 ms) before continuing.
  3. Preemption & Yielding: If a user keystroke arrives (SyncLane), the scheduler aborts the in-progress transition tree, flushes the urgent lane synchronously, and restarts the transition later without dropping INP frames.
TS
function workLoopConcurrent(deadline: number) {
  while (workInProgress !== null && performance.now() < deadline) {
    workInProgress = performUnitOfWork(workInProgress);
  }
  if (workInProgress !== null) {
    // Yield to browser paint & input; resume in next macrotask
    scheduler.postTask(() => workLoopConcurrent(performance.now() + 5));
  }
}

Problem Genealogy

  • 2016 (Recursive Stack Reconciler): React 15 walked components via JS call-stack recursion; a 2,000-node filter update ran uninterruptibly for 120 ms.
  • 2017 (Fiber Linked List): Replaced recursion with heap-allocated fiber pointers (child, sibling, return) so traversal could pause and resume.
  • 2022 (Lane Bitmasks & scheduler.yield): Replaced scalar expiration times with 31-bit lane masks, allowing multiple concurrent transitions to entangle and preempt cleanly.

Production Pitfalls

Production Pitfall
  • Tearing on External Mutable Stores: Reading a mutable global outside React state during an interrupted render causes top and bottom components to show different values unless wrapped in useSyncExternalStore.
  • Starving Low-Priority Lanes: Firing continuous InputContinuousLane updates (such as 60 fps scroll state) indefinitely preempts TransitionLane renders until starvation expiration forces a synchronous flush.
When Not to Use
  • When not to use concurrent transitions: Never wrap controlled text <input> value updates in startTransition; delaying keystroke echo past 16 ms makes typing feel broken and forces synchronous fallback work.

Connections & Logical Next Steps

Seen in Architecture Autopsies