-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Data: Call resolver isFulfilled once per argument set #6360
Conversation
A downside here is that memory use could grow out of control, particularly for selectors which receive objects as arguments, where those arguments may be new references each time. e.g. getFoo( {} ); ...would create a memoize entry each time it's called. While on the surface it seems like a sensible optimization, I'm going to investigate further whether this is actually required for my use-case, or if repeated calls to |
There's still the same issue here as in #5826, where if we don't memoize Re: The issue raised in #6360 (comment): I have a utility library I've been working on in my spare time which could fit well here, for tracking "equivalent" values via complex keys (deeply). I still think it's a reasonable expectation that fulfillment should only ever occur zero or one time per "same" argument set. |
The latest commit a902662 drops |
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 looks good.
What do you think about the performance impact? Is it fine?
import { flowRight, without, mapValues } from 'lodash'; | ||
import memoize from 'memize'; | ||
import { flowRight, without, mapValues, overEvery } from 'lodash'; | ||
import EquivalentKeyMap from 'equivalent-key-map'; |
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.
How many of those packages you have :)
Speaking to computational performance, I think it should be fine enough. Related: https://github.com/aduth/equivalent-key-map#performance-considerations In future maintenance, we might consider to avoid A more practical concern might be memory consumption of tracking each set of arguments for every resolver. Arguably this is a worse concern with the previous implementation, where we were tracking arguments, but not considering deep equality. The internal structure of e.g. These calls:
...would be tracked roughly as: {
"_ekm_index_0": {
"1": {
"_ekm_index_1": {
"2": {
"_ekm_index_2": {
"page": {
"1": {
"_ekm_value": true
},
"2": {
"_ekm_value": true
},
"3": {
"_ekm_value": true
}
}
}
}
}
}
}
} |
a902662
to
7b67a6b
Compare
Related: #6084
This pull request seeks to revise the behavior of a resolver's explicit
isFulfilled
callback to occur a maximum of one time per argument set.isFulfilled
is only necessary to call once, as it is intended to support cases where a fulfillment resolver may not be needed. It is assumed that after the initial case, fulfillment condition would never revert back to needing to be satisfied.Testing instructions:
Ensure unit tests pass: