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
Speed up tpl
#11351
Speed up tpl
#11351
Conversation
- Use a clone of the current Template instead of re-creating everything from scratch - Needs to inject `include` so any defines in the tpl text can be seen. Signed-off-by: Graham Reed <greed@7deadly.org>
@greed42 good job. |
@yxxhero can this be triaged/merged/looked at? Seems like a massive benefit for a little change. |
@bacongobbler @hickeyma @joejulian @scottrigby could you have free time to review this feature? this is a good change. Thanks very much. |
How does this differ from #8371? |
@joejulian main logic is the same. I think we should discuss the PR in the meeting. WDYT? |
Sounds good |
@joejulian my English is not good. So looking forward to your discussion. Thanks very much. |
Actually, no meetings the rest of October. If one isn't any better than the other, we should just add the older one to the next minor release milestone and close the newer. |
@joejulian I'm not familiar with this core logic of |
Though #8371 has an infinite recursion bug with a case that involves |
Except that PR looks to do
also recurses and it doesn't. |
OK I've worked out that the difference between I think that means it is impractical to share Execute code between I will see if I can get some tests for the various edge cases I've observed with my chart library regression suite, and set them up as a separate PR so that this PR does not have additions for tests that cover existing behaviour. associate: https://cs.opensource.google/go/go/+/refs/tags/go1.17.13:src/text/template/template.go;l=227 |
Based on that analysis, I'll add #8371 to the v3.11.0 milestone and hope that the core maintainers have time to get it reviewed and merged. |
As we're using `t.Clone()` we already get the right 'references'. Signed-off-by: Graham Reed <greed@7deadly.org>
Signed-off-by: Graham Reed <greed@7deadly.org>
I've written #11456 to add tests for existing This PR will also need some more commits if #11456 is merged. |
I believe you're saying that #11456 is the better solution now? I'm happy to switch which PR's in the milestone. I can't duplicate the issue so I have to count on you folks that see the problem to guide me here. |
No; #11456 is just tests for existing behaviour. It doesn't fix anything. #11351 (this one) is the fix I would now recommend. The fault in #8371 is with this manifest or anything containing:
Or other define-only things like:
You get a stack overflow, as the empty template never becomes the template
|
I like the speedup. We'll need to take a very careful look at this change as there is potential to break existing charts. |
Thanks. The new tests will fail after merging in main, so I've pushed a merge and the appropriate test changes to this branch. |
Here is some numbers from someone what has something big :) /tmp/helm/bin/helm version
version.BuildInfo{Version:"v3.12+unreleased", GitCommit:"b261a1b1bee93343cf9fe92335d3f1ccf3e24558", GitTreeState:"clean", GoVersion:"go1.20.6"}
time /tmp/helm/bin/helm template . > /dev/null
/tmp/helm/bin/helm template . > /dev/null 0,51s user 0,04s system 159% cpu 0,344 total helm version
version.BuildInfo{Version:"v3.12.2", GitCommit:"1e210a2c8cc5117d1055bfaa5d40f51bbc2e345e", GitTreeState:"clean", GoVersion:"go1.20.5"}
time helm template . > /dev/null
helm template . > /dev/null 22,30s user 0,45s system 147% cpu 15,452 total Considering that a test suite of tests can include up to 800 apps. It will same A TON of time! Unit tests did not have any speed increase, but should be an indicator that it does not break something :) Helm built from this PR: Charts: 1 passed, 1 total
Test Suites: 133 passed, 133 total
Tests: 805 passed, 805 total
Snapshot: 0 passed, 0 total
Time: 8m26.098330718s Helm v3.12.2 Charts: 1 passed, 1 total
Test Suites: 133 passed, 133 total
Tests: 805 passed, 805 total
Snapshot: 0 passed, 0 total
Time: 8m39.303807066s |
speed up!!!! |
@joejulian would you mind to talk the PR in the dev meeting? |
What's the current state here? Will this be fixed with 3.13? |
As 3.13.0 is released, the fix did not make it into it, right? |
We look forward to speeding up!!! |
Please speed up, we need those changes. Thank you! |
We really need this improvement. Please, merge it! |
Need this asap. Merge pls |
Hey! This really cool! Speed up it, please. |
Looks cool! Speed it up, please. |
No news on this, is it still under review ? we're almost 3 months after the first approval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nicely structured and documented.
Speed improvement is crucial for bigger repositories and charts.
LGTM.
@scottrigby and @mattfarina Can we get a final review from you two as well? It seems most issues including previous upstream blockers have been dealth with and this PR would give a significant boost to making Helm more usefull for projects with more complex requirements relying on heavy tpl usage. |
Any update on getting this merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Cool. |
What this PR does / why we need it:
This dramatically improves the performance of the
tpl
function, resolving the issues described in #8002. Our typical charts go from 2-3 minute renders to 1-2 seconds. A particularly pathological one went from 37 minutes to 23 seconds.It uses a clone of the invoking Go
Template
instance, rather that re-building everything from scratch, to isolate the effects of parsing thetpl
text from the calling context. To allowinclude
s ofdefine
s from thetpl
text to continue to work, it also re-definesinclude
within the clone so it can close over the clone itself.Special notes for your reviewer:
The only user-noticeable change should be to performance: actual chart output is unaffected by this change. All tests are unaffected.
If applicable: