-
Notifications
You must be signed in to change notification settings - Fork 47k
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
[Flight][Fizz] ping work within current task #28894
Conversation
Fizz and Flight both currently have a work schedule that enqueues tasks for retrying in a new macrotask. however it means that any given render will be split across multiple tasks even if any thenables that suspend are available within a microtask. This PR updates the ping mechanism for both renderers to schedule retry work on the microtask queue. As we've run into many times in React this is another instance where being able to schedule a microtask to run at the end of the queue would be ideal since we can optimize flushing better.
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.
Good job !!
@@ -589,6 +589,7 @@ describe('ReactDOMFizzServerNode', () => { | |||
if (!hasLoaded) { | |||
throw promise; | |||
} | |||
console.log('rendering'); |
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.
Remove is unnecessary
console.log('rendering'); | |
console.log('rendering'); |
@@ -38,7 +38,7 @@ describe('ReactDOMFizzServerNode', () => { | |||
writable.on('finish', () => { | |||
resolve(); | |||
}); | |||
writable.on('error', () => { | |||
writable.on('error', pl => { |
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.
Param not used
writable.on('error', pl => { | |
writable.on('error', () => { |
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.
This is problematic because there can be many macro tasks already scheduled on the queue from the I/O threads. The goal of the macro task is to exhaust as many of those as possible to be able to render through as much as possible.
This was more efficient when we were able to synchronously render through things that had already loaded in RSC. We still can do that for instrumented promises such as those coming from a Flight stream. I.e. most Fizz work. But ideally we could also do it with more preloads and such with Flight too.
closing in favor of #28907 |
Fizz and Flight both currently have a work schedule that enqueues tasks for retrying in a new macrotask. however it means that any given render will be split across multiple tasks even if any thenables that suspend are available within a microtask. This PR updates the ping mechanism for both renderers to schedule retry work on the microtask queue.
As we've run into many times in React this is another instance where being able to schedule a microtask to run at the end of the queue would be ideal since we can optimize flushing better.