-
Notifications
You must be signed in to change notification settings - Fork 427
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
Memoize pool price calculation #1036
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
readonly getPrice = computedFn( | ||
(coinId: string, vsCurrency?: string): number | undefined => { | ||
if (!vsCurrency) { | ||
vsCurrency = this.defaultVsCurrency; | ||
} |
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.
So computedFn is just memoizing this, were we calling this function repeatedly a lot before?
Am in support of making it memoized / computed!
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.
Yeah basically everything computed on pools is memoized, for some reason this wasn't. So if given the same input, it will return a cached output, which is an absolute need with how often components get rendered as data loads and populates observable properties. However, with all asset prices being computed from pool weights, the one-time (due to memo) recursion still causes quite a delay.
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.
A global ⌘⇧F on computedFn
will come up with a lot of results
@JeremyParish69 thoughts on performance with all assets? We can revert some major ones on coingecko if not satisfactory. |
It seems faster for less assets, but enabling all assets to be calculated from pools is still a bit too much.