-
Notifications
You must be signed in to change notification settings - Fork 1
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
Lazy Context Propagation & useContextSelector hook #3
Conversation
0be9bfa
to
c8343ac
Compare
@@ -1049,6 +1049,142 @@ describe('ReactNewContext', () => { | |||
span(2), | |||
]); | |||
}); | |||
describe('stress test', () => { |
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.
not suggesting we keep this kind of test in place, but wanted to explore implications of this change in a more demanding environment than most tests produce
expect(Scheduler).toFlushAndYield(['A: 4', 'B: 4', 'C: 4']); | ||
} | ||
}); | ||
it('non-context stress test', () => { |
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 tests doesn't use context but acts as a comparable of non-context rendering to see if lazy context adds overhead to work in general
@@ -186,6 +253,198 @@ function scheduleWorkOnParentPath( | |||
} | |||
} | |||
|
|||
export function checkContextDependencies( |
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.
much of the new code in this file could be 'unified' with the existing propagation function to save on LoC but it would make the actual algorithm a little harder to see so it is duplicated
Will end up breaking into separate RFCs and PRs
For now
Lazy Propagation Algorithm: attempts to take advantage of already scheduled work to avoid walking the fiber tree except when necessary (on bailouts that don't go deeper for work on children)
useContextSelector hook: adds a hook that is a modified context reader. it will only schedule work on it's host fiber when the selector value has changed. This hook is intended to be used with the new propagation scheme because it otherwise has numerous problems with selectors running too often / too early.