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

perf: micro optimizations #260

Merged
merged 3 commits into from
Oct 15, 2024
Merged

perf: micro optimizations #260

merged 3 commits into from
Oct 15, 2024

Conversation

boopathi
Copy link
Member

@boopathi boopathi commented Oct 14, 2024

A few performance improvements to compilation based on micro-optimizations / benchmarks -

  1. string concatenation body += seems to be faster than [].join("\n") that is used by generate-function.
  2. Prefer looping over recursion as tail calls are not optimized in v8 as of this writing
  3. Add memoization to simple functions - e.g. joinOriginPaths
  4. Restructure compilations of skip/include to a string[][] and avoid the unnecessary string manipulation. Reduces complexity - simplifies filtering of unwanted trues and code generation.

Next set of optimizations will follow in separate PRs.

Observations with this -

For a very big query (1100 lines formatted, 30+ fragments, 40+ variables, max depth - 8) that takes 1.7s to compile, this PR brings it down to around 1.4s - around 17% faster.

@boopathi
Copy link
Member Author

👍

@boopathi boopathi merged commit 4eab6a5 into main Oct 15, 2024
13 checks passed
@boopathi boopathi deleted the perf-2 branch October 15, 2024 09:17
@boopathi boopathi mentioned this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants