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: optimise template string resolving performance #6685

Merged
merged 43 commits into from
Dec 6, 2024

Conversation

stefreak
Copy link
Member

@stefreak stefreak commented Dec 2, 2024

What this PR does / why we need it:
We optimise the template string resolving performance by
making sure that we only parse each template expression once. Once
parsed, we use the AST to evaluate template expressions.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:
Changes are inspired from #5496

We optimise the template string resolving performance by
making sure that we only parse each template expression once. Once
parsed, we use the AST to evaluate template expressions.
@stefreak stefreak requested review from edvald and eysi09 December 5, 2024 20:24
@stefreak stefreak enabled auto-merge December 5, 2024 20:31
@stefreak stefreak requested a review from twelvemo December 5, 2024 20:31
@stefreak stefreak force-pushed the template-string-perf branch from 0a6afb7 to 3397b0e Compare December 5, 2024 22:39
@stefreak stefreak force-pushed the template-string-perf branch from 620ecc5 to 3a71187 Compare December 6, 2024 07:42
@stefreak stefreak requested a review from 10ko December 6, 2024 11:02
@stefreak stefreak added this pull request to the merge queue Dec 6, 2024
@@ -1,5 +1,5 @@
require:
- build/test/setup.js
- ../../../../build/test/setup.js
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems a little odd - What prompted this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Vovas IDE needed it to be able to run tests, and it didn't seem to have an effect on CI

Copy link
Member Author

Choose a reason for hiding this comment

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

But I agree it's odd, will have a closer look at this

core/src/exceptions.ts Outdated Show resolved Hide resolved
Merged via the queue into main with commit a348564 Dec 6, 2024
42 checks passed
@stefreak stefreak deleted the template-string-perf branch December 6, 2024 11:45
stefreak added a commit that referenced this pull request Dec 9, 2024
operators (`!` and `typeof`).

Older versions of garden did not throw an error when referencing
missing variables from unary operators like `!` and `typeof`. This
commit restores backwards-compatiblity that has been broken in #6685
github-merge-queue bot pushed a commit that referenced this pull request Dec 9, 2024
…ary operators (`!` and `typeof`). (#6695)

fix: retain bug-compatibility for referencing missing variables in unary
operators (`!` and `typeof`).

Older versions of garden did not throw an error when referencing
missing variables from unary operators like `!` and `typeof`. This
commit restores backwards-compatiblity that has been broken in #6685
vvagaytsev added a commit that referenced this pull request Dec 10, 2024
A follow-up for #6685.
Replays #6408 on top of #6685.

Co-authored-by: Steffen Neubauer <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Dec 10, 2024
A follow-up for #6685.
Replays #6408 on top of #6685.

Co-authored-by: Steffen Neubauer <[email protected]>
stefreak added a commit that referenced this pull request Dec 12, 2024
…anifest files

Template strings in Kubernetes manifest files are partially resolved for legacy reasons. The partial resolve behaviour has been changed to improve sanity in #6685 but for kubernetes manifest files, we need to have a version of the old behaviour.

The expected legacy behaviour looks like this:
- If template strings reference variables that do not exist there is no error
- If a template string contains multiple template expressions, each expression can be partially resolved.
- Template expressions are evaluated before parsing yaml, which means that valid yaml with template expressions can be resolved to invalid yaml (e.g. if variable values contain special characters)

This legacy behaviour can lead to quite some surprises and UX problems, for example #5266

I would suggest that we remove this functionality in 0.14.
github-merge-queue bot pushed a commit that referenced this pull request Dec 12, 2024
…anifest files (#6713)

* fix(template): establish backwards bug-compatibility for kubernetes manifest files

Template strings in Kubernetes manifest files are partially resolved for legacy reasons. The partial resolve behaviour has been changed to improve sanity in #6685 but for kubernetes manifest files, we need to have a version of the old behaviour.

The expected legacy behaviour looks like this:
- If template strings reference variables that do not exist there is no error
- If a template string contains multiple template expressions, each expression can be partially resolved.
- Template expressions are evaluated before parsing yaml, which means that valid yaml with template expressions can be resolved to invalid yaml (e.g. if variable values contain special characters)

This legacy behaviour can lead to quite some surprises and UX problems, for example #5266

I would suggest that we remove this functionality in 0.14.

* test: fix running tests on macos

this commit fixes the "cannot find dockerfile" error that plagued us on
macos

* test: add integ tests for legacyAllowPartial behaviour in kubernetes
manifests
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.

5 participants