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

Fix comments performance #4708

Merged
merged 3 commits into from
Jan 9, 2024
Merged

Fix comments performance #4708

merged 3 commits into from
Jan 9, 2024

Conversation

ruggi
Copy link
Contributor

@ruggi ruggi commented Jan 9, 2024

Fix #4707

Problem:

The editor performance degrades heavily when the comments section is open, worsening linearly with the number of threads.

Fix:

The root cause is the useSelf hook, used specifically in useMyThreadReadStatus, which causes constant re-renders. This is due to the fact that useSelf includes the presence data, while we just need the user ID.

So, this PR adds a new hook that only returns the user ID (from the editor state, we don't even need the LB hooks for this) and replaced it wherever useSelf was used inefficiently.

Also, I replaced useEditorState with the ref variant for the canvas deltas used when clicking the threads in the sidebar.

Copy link
Contributor

github-actions bot commented Jan 9, 2024

Try me

Copy link

relativeci bot commented Jan 9, 2024

Job #9778: Bundle Size — 62.2MiB (~+0.01%).

7b4345b(current) vs df0030c master#9759(baseline)

Warning

Bundle contains 66 duplicate packages – View duplicate packages

Bundle metrics  Change 3 changes Regression 2 regressions
                 Current
Job #9778
     Baseline
Job #9759
Regression  Initial JS 45.4MiB(~+0.01%) 45.4MiB
No change  Initial CSS 0B 0B
No change  Cache Invalidation 19.86% 19.86%
No change  Chunks 26 26
No change  Assets 30 30
Change  Modules 4362(+0.02%) 4361
Regression  Duplicate Modules 471(+0.21%) 470
No change  Duplicate Code 30.75% 30.75%
No change  Packages 462 462
No change  Duplicate Packages 65 65
Bundle size by type  Change 1 change Regression 1 regression
                 Current
Job #9778
     Baseline
Job #9759
Regression  JS 62.18MiB (~+0.01%) 62.18MiB
Not changed  HTML 11.54KiB 11.54KiB

View job #9778 reportView fix/comment-section-perf branch activity

@ruggi ruggi marked this pull request as ready for review January 9, 2024 14:07
Copy link
Contributor

github-actions bot commented Jan 9, 2024

Performance test results:
(Chart1)
(Chart2)

@ruggi ruggi merged commit 1b1c4d4 into master Jan 9, 2024
14 checks passed
@ruggi ruggi deleted the fix/comment-section-perf branch January 9, 2024 15:02
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.

Fix performance drop with open comments section
3 participants