[DRAFT] Prototype use of autotracking to optimize subscription behavior#2047
Draft
markerikson wants to merge 8 commits intomasterfrom
Draft
[DRAFT] Prototype use of autotracking to optimize subscription behavior#2047markerikson wants to merge 8 commits intomasterfrom
markerikson wants to merge 8 commits intomasterfrom
Conversation
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit bbf7a4f:
|
0751acc to
bbf7a4f
Compare
Closed
This file contains hidden or 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
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.
This PR:
SubscriptionanduseSelectorto try using autotracking to optimize subscription behavior and avoid executing subscriber+selector callbacks that we already know try to read state that didn't change.For background on autotracking, see:
Notes:
Subscription.tsanduseSelector.tsfiles. My plan is that if I can get this working, I would instead copy-paste the logic into separatecreateTrackedSubscriptionanduseTrackedSelectorfiles, and that you would enable the top-level tracking behavior by passing<Provider createSubscription={createTrackedSubscription}>. That way no one would have to pay the bundle size cost for the additional tracking logic unless they opt in, and all existinguseSelectorusage stays exactly the same.stateis an object, not a primitive. That should be the case in most apps. (Naturally, a bunch of our tests do have just a primitive like0as the state...)useSelectortest suite all passes. Either I've done something very right, or I've done something that has no use at all :)O(n). It's entirely possible everything I've got here is a waste of effort because you're still calling a ton of functions.But now that I've got something that appears to at least run and pass tests, I can start doing more investigation.