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 slow loading/editing of sheet with ~800 comments [master] #3556

Merged
merged 1 commit into from
Nov 8, 2021

Conversation

dennisfrancis
Copy link
Member

Profiling points to updateReplyCount() as the bottleneck where it does
O(N^3) work where N is the number of comments. The innermost loop is
used to find the index of a comment-section in an array using its 'id'.
Turns out that flattening this loop to a < log(N) lookup via a js map
from id -> index pretty much cures the perceived 'slowness'. But we need
to ensure the correctness of the map by updating it whenever
'commentList' is mutated.

Time to load the document with 800 comments (arranged in 50 rows x 16
cols table):

Before the patch: 1min 31 sec
After the patch: 3.5 sec

After-load performance (comment popup/hide/scroll) with this patch is
similar to how it feels in co-6-4 which does not have this issue.

Signed-off-by: Dennis Francis dennis.francis@collabora.com
Change-Id: I4c47f14767cac4c7e9744344d24f646dd27302a6

Checklist

  • Code is properly formatted
  • All commits have Change-Id
  • I have run tests with make check
  • I have issued make run and manually verified that everything looks okay
  • Documentation (manuals or wiki) has been updated or is not required

Profiling points to updateReplyCount() as the bottleneck where it does
O(N^3) work where N is the number of comments. The innermost loop is
used to find the index of a comment-section in an array using its 'id'.
Turns out that flattening this loop to a < log(N) lookup via a js map
from id -> index pretty much cures the perceived 'slowness'. But we need
to ensure the correctness of the map by updating it whenever
'commentList' is mutated.

Time to load the document with 800 comments (arranged in 50 rows x 16
cols table):

Before the patch: 1min 31 sec
After the patch:  3.5 sec

After-load performance (comment popup/hide/scroll) with this patch is
similar to how it feels in co-6-4 which does not have this issue.

Signed-off-by: Dennis Francis <dennis.francis@collabora.com>
Change-Id: I4c47f14767cac4c7e9744344d24f646dd27302a6
Copy link
Contributor

@gokaysatir gokaysatir left a comment

Choose a reason for hiding this comment

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

Thanks for the fix:)

@dennisfrancis dennisfrancis merged commit 39c189c into master Nov 8, 2021
@dennisfrancis dennisfrancis deleted the private/dennisf/comments-slow-load-master branch November 8, 2021 03:46
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.

Loading/Editing a spreadsheet file full with comments is slow.
2 participants