-
Notifications
You must be signed in to change notification settings - Fork 47.2k
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
[Scheduler] Always yield to native macro tasks when a virtual task completes #31787
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Comparing: 34ee391...0310c9b Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: Expand to show
|
@@ -241,6 +244,12 @@ function workLoop(initialTime: number) { | |||
pop(taskQueue); | |||
} | |||
currentTask = peek(taskQueue); | |||
if (enableAlwaysYieldScheduler) { | |||
if (currentTask === null || currentTask.expirationTime > currentTime) { | |||
// This currentTask hasn't expired we yield to the browser task. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't really rely on this once we switch to postTask. React already doesn't rely on this because of batching + Suspense, we have our own expiration times that switch to using the microtask queue once the time has elapsed.
So this is really just for anything at Meta that relies on the starvation protection. Maybe once this lands, that could be its own flag, too, and then Meta can try rolling it out to see what happens.
1990ecf
to
2c088fc
Compare
2c088fc
to
d4ffddb
Compare
d4ffddb
to
411e96c
Compare
…mpletes (#31787) As an alternative to #31784. We should really just always yield each virtual task to a native task. So that it's 1:1 with native tasks. This affects when microtasks within each task happens. This brings us closer to native `postTask` semantics which makes it more seamless to just use that when available. This still doesn't yield when a task expires to protect against starvation. DiffTrain build for [f5077bc](f5077bc)
#31787 introduces an experimental scheduler flag: `enableAlwaysYieldScheduler`, which is turned off for www. There wasn't a SchedulerFeatureFlags fork for native-fb, so the experimental change was enabled in the Scheduler-dev build there which causes test failures and is blocking the sync. #31805 introduces another scheduler flag `enableRequestPaint`, which is set as a `__VARIANT__` on www. I've set this to `true` here to preserve the existing behavior. We can follow up with dynamic flags for native-fb after unblocking the sync.
#31787 introduces an experimental scheduler flag: `enableAlwaysYieldScheduler`, which is turned off for www. There wasn't a SchedulerFeatureFlags fork for native-fb, so the experimental change was enabled in the Scheduler-dev build there which causes test failures and is blocking the sync. #31805 introduces another scheduler flag `enableRequestPaint`, which is set as a `__VARIANT__` on www. I've set this to `true` here to preserve the existing behavior. We can follow up with dynamic flags for native-fb after unblocking the sync. DiffTrain build for [bd76ce5](bd76ce5)
As an alternative to #31784.
We should really just always yield each virtual task to a native task. So that it's 1:1 with native tasks. This affects when microtasks within each task happens. This brings us closer to native
postTask
semantics which makes it more seamless to just use that when available.This still doesn't yield when a task expires to protect against starvation.