Priority Lanes & Time-Slicing Schedulers
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.
Priority Lanes & Time-Slicing
Trace how a 5 ms time-sliced render yields to an urgent keystroke and resumes.
Filtering 2,000 rows assigns TransitionLane (0b1000000) and starts a 5 ms slice.
startTransition(() => setFilter(query));- 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.
- Lane Bitmasking: When
setStatefires insidestartTransition, the scheduler ORs aTransitionLanebit onto the fiber'slanesfield and bubbleschildLanesup to the root. - Work Loop & 5 ms Slice: During
workLoopConcurrent(), the runtime processes one fiber node at a time and checksperformance.now() >= deadline(typically 5 ms) before continuing. - 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.
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
- 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
InputContinuousLaneupdates (such as 60 fps scroll state) indefinitely preemptsTransitionLanerenders until starvation expiration forces a synchronous flush.
- When not to use concurrent transitions: Never wrap controlled text
<input>value updates instartTransition; delaying keystroke echo past 16 ms makes typing feel broken and forces synchronous fallback work.
Connections & Logical Next Steps
Time-slicing schedulers yield control back to the browser event loop between work units.
Chunking reconciliation into 5 ms slices prevents >50 ms long tasks that degrade INP.
Fiber linked-list trees make Virtual DOM reconciliation interruptible at any component boundary.