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

chore: Optimize performance of Assets hooks #30872

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

darkwing
Copy link
Contributor

@darkwing darkwing commented Mar 7, 2025

Memoizes much of the work in the useAccountTotalCrossChainFiatBalance and useAccountTotalFiatBalance hooks

Description

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Copy link
Contributor

github-actions bot commented Mar 7, 2025

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

};
const mergedCrossChainRates: Balances = useMemo(
() => ({
...crossChainContractRates, // todo add confirmation exchange rates?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we even need to do this? Is the todo relevant?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we can confirm that this has a ticket, I'm down to remove this TODO comment.

// to sort by fiat balance, we need to compute this at this level
const tokenExchangeRate = mergedRates[toChecksumAddress(token.address)];
token.tokenFiatAmount =
getTokenFiatAmount(
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice work memoizing all of these!

When I did some investigating, I saw that this function uses an internal class Numeric. This has very high GC rate (since it keeps creating new objects).
^ Just noting this, we don't need to tackle GCs yet.

@metamaskbot
Copy link
Collaborator

Builds ready [816e74e]
Page Load Metrics (2022 ± 141 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint163026372010281135
domContentLoaded157624561951250120
load162826622022294141
domInteractive25111452512
backgroundConnect17334777837
firstReactRender15113352813
getState6138373115
initialActions01000
loadScripts11871867148319694
setupStore973222110
uiStartup187238822401524251
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 482 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants