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

Hook mount/unmount time depends at number of hooks on page #202

Closed
andrewsokolov opened this issue May 24, 2023 · 1 comment · Fixed by #204
Closed

Hook mount/unmount time depends at number of hooks on page #202

andrewsokolov opened this issue May 24, 2023 · 1 comment · Fixed by #204
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@andrewsokolov
Copy link
Contributor

andrewsokolov commented May 24, 2023

For big projects, we have ~ 8000 hooks on the page for multiple stores.
For the biggest store, it's around 4000 on the page.

Mount/unmount each sweet state hook do subscribe/unsubscribe operation on the store.
And implementation of this subscribe/unsubscribe has O(n) complexity, so when need to mount 4000 hooks at once it becomes very painful for UI performance.

Problematic parts highlighted in the screenshot:
Screenshot 2023-05-24 at 12 29 35

Also the video with numbers:

Watch the video

And if we replace js array with Set time of subscribe/unsubscribe close to 0 ms and has O(1) complexity

Screenshot 2023-05-24 at 13 05 25

Mount big view:

Before:
Screenshot 2023-05-24 at 13 03 59
After:
Screenshot 2023-05-24 at 12 59 18

Scroll in virtualized list:

Before:
Screenshot 2023-05-24 at 13 04 16
After:
Screenshot 2023-05-24 at 12 59 48

Unmount big view:

Before:
Screenshot 2023-05-24 at 13 04 33
After:
Screenshot 2023-05-24 at 13 00 08

@albertogasparin albertogasparin added enhancement New feature or request good first issue Good for newcomers labels May 24, 2023
@albertogasparin
Copy link
Collaborator

Great finding!! Let me know if you struggle finding time to raise a PR in the next few days/week 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants