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

perf(SwapModal): improve the performance on tokenSelectorAdaptor #17035

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alexjba
Copy link
Contributor

@alexjba alexjba commented Jan 8, 2025

What does the PR do

Closes #16981

Fixing the performance issues related to the data transformations done in TokenSelectorViewAdaptor.qml by reducing the complexity.

How was the data being processed

There are two inputs in the adaptor. The assets with balances submodels and a plain model of all tokens.
The output consists in a single model holding the assets with transformed balances as plain properties.

There are two options for the adaptor: To show all tokens, or only the tokens with positive balance. When the output model provides all tokens, the ones with positive balance will be the first ones in the list, with a specific sectionName property.

The main culprit for the bad performance was that we've been transforming the two input models, concatenating the items in a single model and then process the model again to remove the duplicates and the other extra items based on network selection or unwanted items from the model with balances.

How it is processed now

The two input models are processed to provide lighter data as two different intermediate models. One holding only the items with positive balance and the other with all the assets, transformed to provide the data in the necessary format. These two models are joined using the left join proxy and filtered with lighter filters.

The proxies are structured in a more natural way processing only the necessary data, avoiding the access to synthetic roles as much as possible.

Improvements

Opening the modal:
before - 6sec
after - ~500ms

Closing the modal:
before - 4 sec
after - immediately

Affected areas

SwapModal
SendModal

High regression risk

The regression risk is limited to the token list processing for the token selectors in Swap and Send modals.
Regressions to confirm:

  • the tokens list provides the expected tokens, with the expected balances for the selected networks
  • the tokens list can be searched
  • the tokens list is updated once the balance is updated
  • the tokens list works well with assets, collectibles and community tokens
  • there is no performance regression

Architecture compliance

Screen.Recording.2025-01-10.at.09.48.42.mov

@status-im-auto
Copy link
Member

status-im-auto commented Jan 8, 2025

Jenkins Builds

Click to see older builds (14)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 68d98ca #1 2025-01-08 08:29:30 ~7 min macos/aarch64 🍎dmg
✔️ 68d98ca #1 2025-01-08 08:31:59 ~9 min tests/nim 📄log
68d98ca #1 2025-01-08 08:34:58 ~12 min tests/ui 📄log
✔️ 68d98ca #1 2025-01-08 08:39:44 ~17 min linux-nix/x86_64 📦tgz
✔️ 68d98ca #1 2025-01-08 08:41:55 ~19 min macos/x86_64 🍎dmg
✔️ 68d98ca #1 2025-01-08 08:44:53 ~22 min linux/x86_64 📦tgz
✔️ 68d98ca #1 2025-01-08 08:49:38 ~27 min windows/x86_64 💿exe
✔️ 15ba288 #2 2025-01-09 09:09:15 ~5 min macos/aarch64 🍎dmg
✔️ 15ba288 #2 2025-01-09 09:13:13 ~9 min tests/nim 📄log
15ba288 #2 2025-01-09 09:16:20 ~12 min tests/ui 📄log
✔️ 15ba288 #2 2025-01-09 09:19:03 ~15 min linux-nix/x86_64 📦tgz
✔️ 15ba288 #2 2025-01-09 09:21:05 ~17 min macos/x86_64 🍎dmg
✔️ 15ba288 #2 2025-01-09 09:24:39 ~21 min linux/x86_64 📦tgz
✔️ 15ba288 #2 2025-01-09 09:29:26 ~25 min windows/x86_64 💿exe
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ a3e3068 #3 2025-01-09 15:47:24 ~5 min macos/aarch64 🍎dmg
✔️ a3e3068 #3 2025-01-09 15:51:19 ~9 min tests/nim 📄log
✔️ a3e3068 #3 2025-01-09 15:52:38 ~10 min tests/ui 📄log
✔️ a3e3068 #3 2025-01-09 15:57:24 ~15 min linux-nix/x86_64 📦tgz
✔️ a3e3068 #3 2025-01-09 15:58:53 ~16 min macos/x86_64 🍎dmg
✔️ a3e3068 #3 2025-01-09 16:02:41 ~20 min linux/x86_64 📦tgz
✔️ a3e3068 #3 2025-01-09 16:06:32 ~24 min windows/x86_64 💿exe
✔️ e593642 #4 2025-01-10 07:53:55 ~8 min macos/aarch64 🍎dmg
✔️ e593642 #4 2025-01-10 07:55:20 ~10 min tests/nim 📄log
✔️ e593642 #4 2025-01-10 07:56:04 ~10 min tests/ui 📄log
✔️ e593642 #4 2025-01-10 08:00:08 ~14 min linux-nix/x86_64 📦tgz
✔️ e593642 #4 2025-01-10 08:02:07 ~16 min macos/x86_64 🍎dmg
✔️ e593642 #4 2025-01-10 08:05:57 ~20 min linux/x86_64 📦tgz
✔️ e593642 #4 2025-01-10 08:09:28 ~24 min windows/x86_64 💿exe

@alexjba alexjba force-pushed the perf/swap-modal branch 2 times, most recently from 15ba288 to a3e3068 Compare January 9, 2025 15:41
@alexjba alexjba marked this pull request as ready for review January 10, 2025 08:33
@alexjba alexjba requested review from micieslak, a team and caybro as code owners January 10, 2025 08:33
@alexjba alexjba requested review from dlipicar, saledjenic, Cuteivist and Khushboo-dev-cpp and removed request for a team January 10, 2025 08:33
@@ -49,38 +49,28 @@ QObject {
property var enabledChainIds: []
property string accountAddress
property bool showCommunityAssets
property string searchString
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was not used anywhere. The search is done on UI level

@virginiabalducci
Copy link

virginiabalducci commented Jan 10, 2025

Regression testing for Swap and Send is in progress.

Send regression (simple send flag Off)

Status: completed, no issues originated on this PR found. ✅

Known issues: (present on master build, unrelated to this PR)

Swap regression

Status: completed

Issues found:

  1. The default output asset on the 'Receive' part of the Swap modal should be SNT. If the user has changed this to a different token, when opening the Swap modal again the last selected token is pre-selected. This is not happening on master build. cc @alexjba
Screen.Recording.2025-01-10.at.2.35.26.PM.mov

Known issues: (present on master build, unrelated to this PR)

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.

[Perf] Swap modal open/close
4 participants