-
-
Couldn't load subscription status.
- Fork 331
Concurrent Renders #1165
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
Concurrent Renders #1165
Conversation
a6dd141 to
dd37697
Compare
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.
Here's a couple of side comments that aren't related to specific LOCs.
- Should we start considering allowing async components? I think they'd lead to some fairly clever design patterns. But, those are completely new design patterns that break ReactPy out of the "ReactJS mold".
- Should we use this PR to add #1136?
- After merging, we will need a new issue for an deduplication algorithm.
- If a
parentis already in the render queue, don't append a new child render. - If a
childis already in the render queue, remove it from the queue.
- If a
- I set this PR to close #557 since JSON patch is the only thing remaining. We've discussed that is a separate can of worms. Patch might not even be worth the computation time, or at the very least it should be toggleable.
- We will need to create an issue to remind ourselves to change this default from
FalsetoTruein v2. Or at least evaluate whether we should do that,
|
I'll be able to finish this off over the weekend. |
af47c3a to
6d969ec
Compare
|
There's still a couple of comments on my original review that need discussion. |
By submitting this pull request you agree that all contributions to this project are made under the MIT license.
Issues
Currently ReactPy renders components sequentially. This means that larger renders can block smaller updates from taking place which impacts responsiveness of the page. Sequential renders are also problematic for async effects since effects which are slow to start and stop can similarly impact the responsiveness of a page.
Solution
This change now allow renders to take place concurrently. To keep things simple, no effort is made to deduplicate renders. For example, if parent and child components are scheduled to render at the same time, both scheduled renders will take place even though a single render of the parent component would be sufficient to update the view.
Concurrent renders are achieved by "asyncifying" the internals of the
Layoutclass. Additionally all scheduled renders immediately result in a "render task" being started. To avoid rendering the same component at the same time, we introduce a semaphore insideLifeCycleHooks that must be acquired before a component is rendered.Note: this contains a subset of the changes originally created in #1093
Checklist
changelog.rsthas been updated with any significant changes.