Skip to content
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

Improve DW v3 performance #1262

Open
wants to merge 5 commits into
base: dw-redesign
Choose a base branch
from
Open

Improve DW v3 performance #1262

wants to merge 5 commits into from

Conversation

nop33
Copy link
Member

@nop33 nop33 commented Feb 14, 2025

I will explain in detail the thought process behind these changes

@nop33 nop33 requested a review from mvaivre February 14, 2025 15:46
Copy link

changeset-bot bot commented Feb 14, 2025

⚠️ No Changeset found

Latest commit: 25f69cf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@nop33 nop33 force-pushed the dw-redesign-ilias branch from 85ca69a to 35bf8cc Compare February 14, 2025 16:18
@@ -50,7 +50,7 @@ const useFetchWalletFtsSymbols = () => {
const {
data: { listedFts },
isLoading: isLoadingTokensByType
} = useFetchWalletTokensByType({ includeAlph: true })
} = useFetchWalletTokensByType({ includeHidden: true })
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some defaults where changed, hence this diff

id,
skip: isLoadingTokenType || tokenType?.stdInterfaceId !== e.TokenStdInterfaceId.NonFungible
})
const { data, isLoading } = useQuery(tokenQuery({ id, networkId, isLoadingFtList, skip: !!listedFt }))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent a lot of time thinking "how can I cache the result of a hook so that it doesn't need to be recomputed every time it's called". Specifically, the problematic hook was useFetchToken. The body of the hook (seen on the left red diff), even though it uses the skip prop, it still requires a lot of computation.

The idea implemented here is to use Tanstack's native caching mechanism. My moving the code into a queryFn we benefit from caching. See below for implementation.

@nop33 nop33 force-pushed the dw-redesign-ilias branch from 35bf8cc to 25f69cf Compare February 14, 2025 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant