-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Callback chain refactoring and performance improvements #1254
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- generalized callback props "stringify"
…mplete ones from firing
…k1` not being triggered
…n if predecessor is prevented or fully incomplete
…is identical to baseline - revert related tests
alexcjohnson
approved these changes
Jun 15, 2020
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.
Fantastic, I think you've got it! 💃
This was referenced Jun 24, 2020
This was referenced Sep 15, 2021
This was referenced Jun 21, 2023
This was referenced Nov 27, 2023
This was referenced Dec 20, 2023
This was referenced May 13, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of a larger performance rework. This PR proposes to break up the callback chain into smaller constituents by rewriting it using (1) a state-machine model where callbacks transition through various states (eg. requested, prioritized, executing, watched, executed, stored) that offer more limited logic each step of the way and hopefully easier optimization paths. (2) by handling derived store props and state transitions in (1) through the use of store observers.
pendingCallbacks
from the store and replace it with more easily used data structures for evaluating if:a. the app is ready (no callbacks to process)
b. the component (or one if its children, for loading components) is awaiting the result of a callback
connect
from TreeContainer componenta. Resolve
loading_state
in parentb. Resolve a
loading state hash
that can be used to decide if the parent needs to be re-rendered for its childrenc. Use
context
to provide shared data that do not affect re-renders (eg. graphs, etc.) - this replaces theconnect
usageCompanions
DCC: plotly/dash-core-components#810 (testing only)
Table: plotly/dash-table#785 (contains a tabe fix)
Docs: https://github.com/plotly/dash-docs/pull/888 (testing only)
There are some issues in the companion PRs but they seem related to CI only / the tests themselves are passing.
https://percy.io/plotly/dash-docs/builds/5455921/view/319601375/1280?mode=diff&browser=firefox&snapshot=319601375 (missing number of pages)
Performance
Gains increase as the number of displayed elements increases and can be explained by (1) less renders, (2) less expensive checks for states (eg. is_loading, shouldComponentUpdate).
dash.plotly.com/ vs branch (few components, none heavy, no callbacks)
JS time: 625ms vs 592ms (20 runs, p=0.08)
Total time: 1198ms vs 888ms (20 runs, p<=0.001)
dash.plotly.com/datatable/interactivity (few components, heavy: table/graph, w/ callbacks)
No significant difference after 10 runs.
JS time: 2488ms vs 2435ms (10 runs, p ~ 0.70)
Total time: 3430ms vs 3369ms (10 runs, p ~ 0.70)
HTML Table with 1000 rows (dev vs. branch) (lots of lightweight components, no callbacks)
JS time: 2706ms vs 1072ms (5 runs, p<=0.001)
Total time: 3460ms vs 1817ms (5 runs, p<=0.001)
HTML Table with 5000 rows (dev vs. branch) (lots of lightweight components, no callbacks)
JS time: 8412ms vs 3835ms (5 runs, p<=0.001)
Total time: N/A, devtools terminated test too early for dev and numbers were no significant - JS times were obtained by starting/ending the tests manually