Skip to content

Work in progress to improve performance and garbage collection#792

Draft
jacob-kofoed wants to merge 3 commits into
mainfrom
lib-performance
Draft

Work in progress to improve performance and garbage collection#792
jacob-kofoed wants to merge 3 commits into
mainfrom
lib-performance

Conversation

@jacob-kofoed
Copy link
Copy Markdown
Contributor

@jacob-kofoed jacob-kofoed commented Feb 25, 2026

Draft PR. Requires testing to see actual real-life benefits, as code is more obfuscated.

Classic example of fast code being a lot less readable than clean one. General idea of this PR is to remove object and array allocations (Object.entries etc.). Benefits are pretty minimal per execution, so this kind of optimisation only really make sense in the core for now, which can run thousand of times for even small changes in data.

Quick metrics:

  • Opening complex formula (2232ms -> 1384ms): 61.3% faster
  • Closing complex formula (264ms -> 224ms): 17.6% faster
  • Opening file overview (192ms -> 120ms): 60% faster

Probably more to come for as substantial time is still spent on GC, even with these changes.

Comment thread packages/core/src/formula/formula.ts Outdated
logErrors: boolean
}

const FORMULA_TYPES = [
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not guaranteed that browsers would not reallocate this array every time.

if (first) {
return { ...input, Args: { key: first[0], value: first[1] } }
for (const key in items) {
if (Object.prototype.hasOwnProperty.call(items, key)) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This check is probably not needed, but would be a breaking change for someone looping over prototyped objects.

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.

1 participant