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

Implement caching for import_* calls if context isn't forced. #67217

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jfindlay
Copy link
Contributor

@jfindlay jfindlay commented Feb 1, 2025

Basically the notion is for import_* tags to cache the content rendered if it's just using the global render context; that cache lives for the duration of the minion render (or state render if triggered via minion side).

This is an optimization for heavy users of import_yaml; in general pillarstack is a better approach if one can structure their configurables that way, but for codebases not yet there (or limited due to other reasons) improving import_* performance is beneficial.

For example, the codebase I work against- this reduces our pillar render time from ~74s to ~65s; that's something of an edge case for our renders, but the complexity of the target is why it's so large, and why an optimization like this has value.

This logic is wired such that if context is enabled for the import--meaning the target does not have a stable render context (like one has in a state or while doing a pillar render)--caching is disabled automatically.

What does this PR do?

What issues does this PR fix or reference?

Fixes

Previous Behavior

Remove this section if not relevant

New Behavior

Remove this section if not relevant

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes/No

Please review Salt's Contributing Guide for best practices, including the
PR Guidelines.

See GitHub's page on GPG signing for more information about signing commits with GPG.

Basically the notion is for `import_*` tags to cache the content
rendered if it's just using the global render context; that cache lives
for the duration of the minion render (or state render if triggered via
minion side).

This is an optimization for heavy users of `import_yaml`; in general
pillarstack is a better approach if one can structure their
configurables that way, but for codebases not yet there (or limited due
to other reasons) improving `import_*` performance is beneficial.

For example, the codebase I work against- this reduces our pillar render time
from ~74s to ~65s; that's something of an edge case for our renders, but
the complexity of the target is why it's so large, and why an optimization
like this has value.

This logic is wired such that if context is enabled for the
`import`--meaning the target does not have a stable render context (like
one has in a state or while doing a pillar render)--caching is disabled
automatically.
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