Skip to content

Commit

Permalink
Delete unused eventTimes Fiber field
Browse files Browse the repository at this point in the history
`eventTimes` represents the timestamp of the event that scheduled an
update. The last remaining use for this field was the JND delay that was
removed in facebook#26597. We can now delete it, and all the code we had for
tracking it.
  • Loading branch information
acdlite committed Apr 11, 2023
1 parent 0b931f9 commit b4021d6
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 133 deletions.
10 changes: 1 addition & 9 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ import {
OffscreenLane,
DefaultHydrationLane,
SomeRetryLane,
NoTimestamp,
includesSomeLane,
laneToLanes,
removeLanes,
Expand Down Expand Up @@ -2876,15 +2875,8 @@ function updateDehydratedSuspenseComponent(
// is one of the very rare times where we mutate the current tree
// during the render phase.
suspenseState.retryLane = attemptHydrationAtLane;
// TODO: Ideally this would inherit the event time of the current render
const eventTime = NoTimestamp;
enqueueConcurrentRenderForLane(current, attemptHydrationAtLane);
scheduleUpdateOnFiber(
root,
current,
attemptHydrationAtLane,
eventTime,
);
scheduleUpdateOnFiber(root, current, attemptHydrationAtLane);

// Throw a special object that signals to the work loop that it should
// interrupt the current render.
Expand Down
15 changes: 4 additions & 11 deletions packages/react-reconciler/src/ReactFiberClassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ import {
emptyContextObject,
} from './ReactFiberContext';
import {readContext, checkIfContextChanged} from './ReactFiberNewContext';
import {
requestEventTime,
requestUpdateLane,
scheduleUpdateOnFiber,
} from './ReactFiberWorkLoop';
import {requestUpdateLane, scheduleUpdateOnFiber} from './ReactFiberWorkLoop';
import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing';
import {
markForceUpdateScheduled,
Expand Down Expand Up @@ -213,8 +209,7 @@ const classComponentUpdater = {

const root = enqueueUpdate(fiber, update, lane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
scheduleUpdateOnFiber(root, fiber, lane);
entangleTransitions(root, fiber, lane);
}

Expand Down Expand Up @@ -248,8 +243,7 @@ const classComponentUpdater = {

const root = enqueueUpdate(fiber, update, lane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
scheduleUpdateOnFiber(root, fiber, lane);
entangleTransitions(root, fiber, lane);
}

Expand Down Expand Up @@ -283,8 +277,7 @@ const classComponentUpdater = {

const root = enqueueUpdate(fiber, update, lane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
scheduleUpdateOnFiber(root, fiber, lane);
entangleTransitions(root, fiber, lane);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/react-reconciler/src/ReactFiberCommitWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
} from './ReactFiberConfig';
import type {Fiber, FiberRoot} from './ReactInternalTypes';
import type {Lanes} from './ReactFiberLane';
import {NoTimestamp, SyncLane} from './ReactFiberLane';
import {SyncLane} from './ReactFiberLane';
import type {SuspenseState, RetryQueue} from './ReactFiberSuspenseComponent';
import type {UpdateQueue} from './ReactFiberClassUpdateQueue';
import type {FunctionComponentUpdateQueue} from './ReactFiberHooks';
Expand Down Expand Up @@ -2415,7 +2415,7 @@ export function detachOffscreenInstance(instance: OffscreenInstance): void {
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
instance._pendingVisibility |= OffscreenDetached;
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
}

Expand All @@ -2435,7 +2435,7 @@ export function attachOffscreenInstance(instance: OffscreenInstance): void {
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
instance._pendingVisibility &= ~OffscreenDetached;
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
}

Expand Down
13 changes: 4 additions & 9 deletions packages/react-reconciler/src/ReactFiberHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import {
isTransitionLane,
markRootEntangled,
markRootMutableRead,
NoTimestamp,
} from './ReactFiberLane';
import {
ContinuousEventPriority,
Expand Down Expand Up @@ -101,7 +100,6 @@ import {
getWorkInProgressRootRenderLanes,
scheduleUpdateOnFiber,
requestUpdateLane,
requestEventTime,
markSkippedUpdateLanes,
isInvalidExecutionContextForEventFunction,
} from './ReactFiberWorkLoop';
Expand Down Expand Up @@ -1837,7 +1835,7 @@ function checkIfSnapshotChanged<T>(inst: StoreInstance<T>): boolean {
function forceStoreRerender(fiber: Fiber) {
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
}

Expand Down Expand Up @@ -2558,8 +2556,7 @@ function refreshCache<T>(fiber: Fiber, seedKey: ?() => T, seedValue: T): void {
const refreshUpdate = createLegacyQueueUpdate(lane);
const root = enqueueLegacyQueueUpdate(provider, refreshUpdate, lane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, provider, lane, eventTime);
scheduleUpdateOnFiber(root, provider, lane);
entangleLegacyQueueTransitions(root, provider, lane);
}

Expand Down Expand Up @@ -2623,8 +2620,7 @@ function dispatchReducerAction<S, A>(
} else {
const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
scheduleUpdateOnFiber(root, fiber, lane);
entangleTransitionUpdate(root, queue, lane);
}
}
Expand Down Expand Up @@ -2706,8 +2702,7 @@ function dispatchSetState<S, A>(

const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
scheduleUpdateOnFiber(root, fiber, lane);
entangleTransitionUpdate(root, queue, lane);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-reconciler/src/ReactFiberHotReloading.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
import {enqueueConcurrentRenderForLane} from './ReactFiberConcurrentUpdates';
import {updateContainer} from './ReactFiberReconciler';
import {emptyContextObject} from './ReactFiberContext';
import {SyncLane, NoTimestamp} from './ReactFiberLane';
import {SyncLane} from './ReactFiberLane';
import {
ClassComponent,
FunctionComponent,
Expand Down Expand Up @@ -328,7 +328,7 @@ function scheduleFibersWithFamiliesRecursively(
if (needsRemount || needsRender) {
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
}
if (child !== null && !needsRemount) {
Expand Down
33 changes: 1 addition & 32 deletions packages/react-reconciler/src/ReactFiberLane.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,25 +319,6 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
return nextLanes;
}

export function getMostRecentEventTime(root: FiberRoot, lanes: Lanes): number {
const eventTimes = root.eventTimes;

let mostRecentEventTime = NoTimestamp;
while (lanes > 0) {
const index = pickArbitraryLaneIndex(lanes);
const lane = 1 << index;

const eventTime = eventTimes[index];
if (eventTime > mostRecentEventTime) {
mostRecentEventTime = eventTime;
}

lanes &= ~lane;
}

return mostRecentEventTime;
}

function computeExpirationTime(lane: Lane, currentTime: number) {
switch (lane) {
case SyncHydrationLane:
Expand Down Expand Up @@ -599,11 +580,7 @@ export function createLaneMap<T>(initial: T): LaneMap<T> {
return laneMap;
}

export function markRootUpdated(
root: FiberRoot,
updateLane: Lane,
eventTime: number,
) {
export function markRootUpdated(root: FiberRoot, updateLane: Lane) {
root.pendingLanes |= updateLane;

// If there are any suspended transitions, it's possible this new update
Expand All @@ -622,12 +599,6 @@ export function markRootUpdated(
root.suspendedLanes = NoLanes;
root.pingedLanes = NoLanes;
}

const eventTimes = root.eventTimes;
const index = laneToIndex(updateLane);
// We can always overwrite an existing timestamp because we prefer the most
// recent event, and we assume time is monotonically increasing.
eventTimes[index] = eventTime;
}

export function markRootSuspended(root: FiberRoot, suspendedLanes: Lanes) {
Expand Down Expand Up @@ -672,7 +643,6 @@ export function markRootFinished(root: FiberRoot, remainingLanes: Lanes) {
root.errorRecoveryDisabledLanes &= remainingLanes;

const entanglements = root.entanglements;
const eventTimes = root.eventTimes;
const expirationTimes = root.expirationTimes;
const hiddenUpdates = root.hiddenUpdates;

Expand All @@ -683,7 +653,6 @@ export function markRootFinished(root: FiberRoot, remainingLanes: Lanes) {
const lane = 1 << index;

entanglements[index] = NoLanes;
eventTimes[index] = NoTimestamp;
expirationTimes[index] = NoTimestamp;

const hiddenUpdatesForLane = hiddenUpdates[index];
Expand Down
31 changes: 12 additions & 19 deletions packages/react-reconciler/src/ReactFiberReconciler.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ import {
onScheduleRoot,
} from './ReactFiberDevToolsHook';
import {
requestEventTime,
requestUpdateLane,
scheduleUpdateOnFiber,
scheduleInitialHydrationOnRoot,
Expand Down Expand Up @@ -84,7 +83,6 @@ import {StrictLegacyMode} from './ReactTypeOfMode';
import {
SyncLane,
SelectiveHydrationLane,
NoTimestamp,
getHighestPriorityPendingLanes,
higherPriorityLane,
} from './ReactFiberLane';
Expand Down Expand Up @@ -311,9 +309,8 @@ export function createHydrationContainer(
const update = createUpdate(lane);
update.callback =
callback !== undefined && callback !== null ? callback : null;
const eventTime = requestEventTime();
enqueueUpdate(current, update, lane);
scheduleInitialHydrationOnRoot(root, lane, eventTime);
scheduleInitialHydrationOnRoot(root, lane);

return root;
}
Expand Down Expand Up @@ -379,8 +376,7 @@ export function updateContainer(

const root = enqueueUpdate(current, update, lane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, current, lane, eventTime);
scheduleUpdateOnFiber(root, current, lane);
entangleTransitions(root, current, lane);
}

Expand Down Expand Up @@ -427,8 +423,7 @@ export function attemptSynchronousHydration(fiber: Fiber): void {
flushSync(() => {
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, SyncLane, eventTime);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
});
// If we're still blocked after this, we need to increase
Expand Down Expand Up @@ -471,8 +466,7 @@ export function attemptContinuousHydration(fiber: Fiber): void {
const lane = SelectiveHydrationLane;
const root = enqueueConcurrentRenderForLane(fiber, lane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
scheduleUpdateOnFiber(root, fiber, lane);
}
markRetryLaneIfNotHydrated(fiber, lane);
}
Expand All @@ -486,8 +480,7 @@ export function attemptHydrationAtCurrentPriority(fiber: Fiber): void {
const lane = requestUpdateLane(fiber);
const root = enqueueConcurrentRenderForLane(fiber, lane);
if (root !== null) {
const eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
scheduleUpdateOnFiber(root, fiber, lane);
}
markRetryLaneIfNotHydrated(fiber, lane);
}
Expand Down Expand Up @@ -666,7 +659,7 @@ if (__DEV__) {

const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
}
};
Expand All @@ -690,7 +683,7 @@ if (__DEV__) {

const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
}
};
Expand All @@ -715,7 +708,7 @@ if (__DEV__) {

const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
}
};
Expand All @@ -728,7 +721,7 @@ if (__DEV__) {
}
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
};
overridePropsDeletePath = (fiber: Fiber, path: Array<string | number>) => {
Expand All @@ -738,7 +731,7 @@ if (__DEV__) {
}
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
};
overridePropsRenamePath = (
Expand All @@ -752,14 +745,14 @@ if (__DEV__) {
}
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
};

scheduleUpdate = (fiber: Fiber) => {
const root = enqueueConcurrentRenderForLane(fiber, SyncLane);
if (root !== null) {
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
scheduleUpdateOnFiber(root, fiber, SyncLane);
}
};

Expand Down
1 change: 0 additions & 1 deletion packages/react-reconciler/src/ReactFiberRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ function FiberRootNode(
this.next = null;
this.callbackNode = null;
this.callbackPriority = NoLane;
this.eventTimes = createLaneMap(NoLanes);
this.expirationTimes = createLaneMap(NoTimestamp);

this.pendingLanes = NoLanes;
Expand Down
Loading

0 comments on commit b4021d6

Please sign in to comment.