Skip to content

Commit

Permalink
Remove eventTime field from class Update type (#26219)
Browse files Browse the repository at this point in the history
`eventTime` is a vestigial field that can be cleaned up. It was
originally used as part of the starvation mechanism but it's since been
replaced by a per-lane field on the root.

This is a part of a series of smaller refactors I'm doing to
simplify/speed up the `setState` path, related to the Sync Unification
project that @tyao1 has been working on.

DiffTrain build for commit c04b180.
  • Loading branch information
acdlite committed Feb 22, 2023
1 parent b6024b9 commit e246c05
Show file tree
Hide file tree
Showing 28 changed files with 494 additions and 675 deletions.
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
212b89fa25fd0a39473e845d1665d45f9da9dad3
c04b18070145b82111e1162729f4776f4d2c6112
2 changes: 1 addition & 1 deletion compiled/facebook-www/REVISION_TRANSFORMS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
212b89fa25fd0a39473e845d1665d45f9da9dad3
c04b18070145b82111e1162729f4776f4d2c6112
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-classic-212b89fa2-20230221";
var ReactVersion = "18.3.0-www-classic-c04b18070-20230222";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-dev.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (
}
"use strict";

var ReactVersion = "18.3.0-www-modern-212b89fa2-20230221";
var ReactVersion = "18.3.0-www-modern-c04b18070-20230222";

// ATTENTION
// When adding new symbols to this file,
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -646,4 +646,4 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-212b89fa2-20230221";
exports.version = "18.3.0-www-classic-c04b18070-20230222";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-prod.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,4 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-212b89fa2-20230221";
exports.version = "18.3.0-www-modern-c04b18070-20230222";
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-classic-212b89fa2-20230221";
exports.version = "18.3.0-www-classic-c04b18070-20230222";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
2 changes: 1 addition & 1 deletion compiled/facebook-www/React-profiling.modern.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ exports.useSyncExternalStore = function (
);
};
exports.useTransition = useTransition;
exports.version = "18.3.0-www-modern-212b89fa2-20230221";
exports.version = "18.3.0-www-modern-c04b18070-20230222";

/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
if (
Expand Down
40 changes: 17 additions & 23 deletions compiled/facebook-www/ReactART-dev.classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function _assertThisInitialized(self) {
return self;
}

var ReactVersion = "18.3.0-www-classic-212b89fa2-20230221";
var ReactVersion = "18.3.0-www-classic-c04b18070-20230222";

var LegacyRoot = 0;
var ConcurrentRoot = 1;
Expand Down Expand Up @@ -4321,9 +4321,8 @@ function cloneUpdateQueue(current, workInProgress) {
workInProgress.updateQueue = clone;
}
}
function createUpdate(eventTime, lane) {
function createUpdate(lane) {
var update = {
eventTime: eventTime,
lane: lane,
tag: UpdateState,
payload: null,
Expand Down Expand Up @@ -4439,7 +4438,6 @@ function enqueueCapturedUpdate(workInProgress, capturedUpdate) {

do {
var clone = {
eventTime: update.eventTime,
lane: update.lane,
tag: update.tag,
payload: update.payload,
Expand Down Expand Up @@ -4652,11 +4650,9 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) {
var update = firstBaseUpdate;

do {
// TODO: Don't need this field anymore
var updateEventTime = update.eventTime; // An extra OffscreenLane bit is added to updates that were made to
// An extra OffscreenLane bit is added to updates that were made to
// a hidden tree, so that we can distinguish them from updates that were
// already there when the tree was hidden.

var updateLane = removeLanes(update.lane, OffscreenLane);
var isHiddenUpdate = updateLane !== update.lane; // Check if this update was made while the tree was hidden. If so, then
// it's not a "base" update and we should disregard the extra base lanes
Expand All @@ -4671,7 +4667,6 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) {
// skipped update, the previous update/state is the new base
// update/state.
var clone = {
eventTime: updateEventTime,
lane: updateLane,
tag: update.tag,
payload: update.payload,
Expand All @@ -4691,7 +4686,6 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) {
// This update does have sufficient priority.
if (newLastBaseUpdate !== null) {
var _clone = {
eventTime: updateEventTime,
// This update is going to be committed so we never want uncommit
// it. Using NoLane works because 0 is a subset of all bitmasks, so
// this will never be skipped by the check above.
Expand Down Expand Up @@ -9302,11 +9296,11 @@ function refreshCache(fiber, seedKey, seedValue) {
case HostRoot: {
// Schedule an update on the cache boundary to trigger a refresh.
var lane = requestUpdateLane(provider);
var eventTime = requestEventTime();
var refreshUpdate = createUpdate(eventTime, lane);
var refreshUpdate = createUpdate(lane);
var root = enqueueUpdate(provider, refreshUpdate, lane);

if (root !== null) {
var eventTime = requestEventTime();
scheduleUpdateOnFiber(root, provider, lane, eventTime);
entangleTransitions(root, provider, lane);
} // TODO: If a refresh never commits, the new cache created here must be
Expand Down Expand Up @@ -10915,9 +10909,8 @@ var classComponentUpdater = {
// $FlowFixMe[missing-local-annot]
enqueueSetState: function (inst, payload, callback) {
var fiber = get(inst);
var eventTime = requestEventTime();
var lane = requestUpdateLane(fiber);
var update = createUpdate(eventTime, lane);
var update = createUpdate(lane);
update.payload = payload;

if (callback !== undefined && callback !== null) {
Expand All @@ -10931,6 +10924,7 @@ var classComponentUpdater = {
var root = enqueueUpdate(fiber, update, lane);

if (root !== null) {
var eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
entangleTransitions(root, fiber, lane);
}
Expand All @@ -10950,9 +10944,8 @@ var classComponentUpdater = {
},
enqueueReplaceState: function (inst, payload, callback) {
var fiber = get(inst);
var eventTime = requestEventTime();
var lane = requestUpdateLane(fiber);
var update = createUpdate(eventTime, lane);
var update = createUpdate(lane);
update.tag = ReplaceState;
update.payload = payload;

Expand All @@ -10967,6 +10960,7 @@ var classComponentUpdater = {
var root = enqueueUpdate(fiber, update, lane);

if (root !== null) {
var eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
entangleTransitions(root, fiber, lane);
}
Expand All @@ -10987,9 +10981,8 @@ var classComponentUpdater = {
// $FlowFixMe[missing-local-annot]
enqueueForceUpdate: function (inst, callback) {
var fiber = get(inst);
var eventTime = requestEventTime();
var lane = requestUpdateLane(fiber);
var update = createUpdate(eventTime, lane);
var update = createUpdate(lane);
update.tag = ForceUpdate;

if (callback !== undefined && callback !== null) {
Expand All @@ -11003,6 +10996,7 @@ var classComponentUpdater = {
var root = enqueueUpdate(fiber, update, lane);

if (root !== null) {
var eventTime = requestEventTime();
scheduleUpdateOnFiber(root, fiber, lane, eventTime);
entangleTransitions(root, fiber, lane);
}
Expand Down Expand Up @@ -12078,7 +12072,7 @@ function logCapturedError(boundary, errorInfo) {
}

function createRootErrorUpdate(fiber, errorInfo, lane) {
var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null.
var update = createUpdate(lane); // Unmount the root by rendering null.

update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property
// being called "element".
Expand All @@ -12097,7 +12091,7 @@ function createRootErrorUpdate(fiber, errorInfo, lane) {
}

function createClassErrorUpdate(fiber, errorInfo, lane) {
var update = createUpdate(NoTimestamp, lane);
var update = createUpdate(lane);
update.tag = CaptureUpdate;
var getDerivedStateFromError = fiber.type.getDerivedStateFromError;

Expand Down Expand Up @@ -12257,7 +12251,7 @@ function markSuspenseBoundaryShouldCapture(
// When we try rendering again, we should not reuse the current fiber,
// since it's known to be in an inconsistent state. Use a force update to
// prevent a bail out.
var update = createUpdate(NoTimestamp, SyncLane);
var update = createUpdate(SyncLane);
update.tag = ForceUpdate;
enqueueUpdate(sourceFiber, update, SyncLane);
}
Expand Down Expand Up @@ -16444,7 +16438,7 @@ function propagateContextChange_eager(workInProgress, context, renderLanes) {
if (fiber.tag === ClassComponent) {
// Schedule a force update on the work-in-progress.
var lane = pickArbitraryLane(renderLanes);
var update = createUpdate(NoTimestamp, lane);
var update = createUpdate(lane);
update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the
// update to the current fiber, too, which means it will persist even if
// this render is thrown away. Since it's a race condition, not sure it's
Expand Down Expand Up @@ -27517,7 +27511,6 @@ function updateContainer(element, container, parentComponent, callback) {
}

var current$1 = container.current;
var eventTime = requestEventTime();
var lane = requestUpdateLane(current$1);

if (enableSchedulingProfiler) {
Expand Down Expand Up @@ -27546,7 +27539,7 @@ function updateContainer(element, container, parentComponent, callback) {
}
}

var update = createUpdate(eventTime, lane); // Caution: React DevTools currently depends on this property
var update = createUpdate(lane); // Caution: React DevTools currently depends on this property
// being called "element".

update.payload = {
Expand All @@ -27571,6 +27564,7 @@ function updateContainer(element, container, parentComponent, callback) {
var root = enqueueUpdate(current$1, update, lane);

if (root !== null) {
var eventTime = requestEventTime();
scheduleUpdateOnFiber(root, current$1, lane, eventTime);
entangleTransitions(root, current$1, lane);
}
Expand Down
Loading

0 comments on commit e246c05

Please sign in to comment.