-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add profile block and profiling of import_* jinja calls #57850
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41a24b0
to
757daa5
Compare
757daa5
to
b88e2f8
Compare
cmcmarrow
previously approved these changes
Aug 6, 2020
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.
Looks good thanks for the PR!
For some of the more complex salt code--or when salt functions lack timing stats themselves--it's desirable to be able to do thus: ```sls {%- profile as 'inner test' %} < jinja-code > {%- endprofile %} ``` And get a log line like thus: ``` 2019-08-05 22:10:59,531 [salt.utils.jinja ][PROFILE ][26803] Time (in seconds) to render profile block 'inner test': 5.96046447754e-06 ``` This commit adds a new `profile` block tag that emits these log statements. The same machinery used to support the `profile` block tag is also wired into `import_*` blocks. For example: ```sls {%- import grains.sls as 'blah' %} ``` results in the following log statement: ``` 2019-08-05 22:10:59,542 [salt.utils.jinja ][PROFILE ][26803] Time (in seconds) to render import_yaml 'grains.sls': 0.0106961727142 ```
b88e2f8
to
0c13eb0
Compare
The pre-commit errors are not from my changes. It looks like you've enforced CI style checks before refactoring the codebase. |
dwoz
approved these changes
Oct 5, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Feature
new functionality including changes to functionality and code refactors, etc.
has-failing-test
Magnesium
Mg release after Na prior to Al
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Originally from @ferringb.
What does this PR do?
Add the
profile
jinja block to enable profiling of individual lines or blocks within sls files and enable the same profile mechanism forimport_yaml
,import_json
,import_text
.What issues does this PR fix or reference?
Fixes: #57849
Motivation
When working with a very large codebase, it becomes more important to trace inefficiencies with state and pillar render times. The
profile
jinja block enables the user to get finely detailed information on the most expensive areas in the codebase.Example
Setup
Output
The ***asterisked lines*** below are new and correspond to the
profile
blocks in the code above.Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes