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

Formula calculation optimisations #545

Merged
merged 4 commits into from May 20, 2024
Merged

Conversation

sanchit3008
Copy link
Collaborator

@sanchit3008 sanchit3008 commented May 8, 2024

Resolves #486

Right now, pasting formulae into sheets is roughly an $O(n^2)$ operation due to the linear search loop on the entire calcChain being run for each formula update.

This PR uses a Set instead of the calcChain array to optimise the search operation into $O(log n)$ - hence converting the entire operation to $O(nlogn)$ more or less. The set is computed only once for the entire operation, which makes paste operations less than ~15 rows more expensive, but for more rows it is many orders of magnitude faster.

Here are my findings for the calculation processing time (blue is the current code in master, red is the code in this branch) -

image

@sanchit3008 sanchit3008 requested a review from zyc9012 May 8, 2024 11:13
@sanchit3008 sanchit3008 merged commit 5b5c087 into master May 20, 2024
2 checks passed
@sanchit3008 sanchit3008 deleted the feat/formula-optimization branch May 20, 2024 16:37
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.

Performance issues with big sheets
1 participant