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

Make slots work with parallel=true #56221

Merged
merged 2 commits into from
Apr 14, 2020
Merged

Conversation

max-arnold
Copy link
Contributor

Previous Behavior

Slots were completely ignored when states used parallel: true

New Behavior

Slots are expanded as expected

Tests written?

Yes

Commits signed with GPG?

No

@DmitryKuzmenko I'm not sure if you had any reasons not to expand slots in parallel mode. Any downsides? Please review the PR if you have some time.

@max-arnold max-arnold requested a review from a team as a code owner February 21, 2020 11:37
@ghost ghost requested a review from cmcmarrow February 21, 2020 11:37
@max-arnold
Copy link
Contributor Author

re-run full amazon1-py2
re-run full amazon2-py2
re-run full centos6-py2

DmitryKuzmenko
DmitryKuzmenko previously approved these changes Feb 26, 2020
@DmitryKuzmenko
Copy link
Contributor

Good catch @max-arnold ! Thank you for PR

Copy link
Contributor

@dhiltonp dhiltonp left a comment

Choose a reason for hiding this comment

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

The other execution of format_slots is like this:

                    # Execute the state function
                    if not low.get('__prereq__') and low.get('parallel'):
                        # run the state call in parallel, but only if not in a prereq
                        ret = self.call_parallel(cdata, low)
                    else:
                        self.format_slots(cdata)
                        ret = self.states[cdata['full']](*cdata['args'],
                                                         **cdata['kwargs'])

format_slots loads the cdata structure, would this still work if your code altered the main invocation like this:

                    # Execute the state function
                    self.format_slots(cdata)
                    if not low.get('__prereq__') and low.get('parallel'):
                        # run the state call in parallel, but only if not in a prereq
                        ret = self.call_parallel(cdata, low)
                    else:
                        ret = self.states[cdata['full']](*cdata['args'],
                                                         **cdata['kwargs'])

If it does work, I believe that would be better.

What do you think?

@max-arnold
Copy link
Contributor Author

@dhiltonp This approach is less preferred, because the slots expansion won't be paralellized.

@dhiltonp
Copy link
Contributor

Parallelizing the expansion seems bad. We can either expand it once, or expand it tons of times, duplicating work.

What am I missing?

@max-arnold
Copy link
Contributor Author

Could you please elaborate on how we are duplicating the work? Slots are basically execution module calls, and those calls could be expensive. I may be missing something, but I believe that if we offload a state execution to a separate process, it makes total sense to expand slots (that belong to the state) in the same separate process. Otherwise the state would not be paralellized as a whole.

cmcmarrow
cmcmarrow previously approved these changes Mar 18, 2020
@DmitryKuzmenko
Copy link
Contributor

@dhiltonp one more argument to keep this as is: slots expansion must be the last step prior to the state execution. So placing it far from the execution makes a risk. If we'll have a performance penalties lets work on it in the future. Currently it's more correct to keep the slots call right before the state call.

@max-arnold
Copy link
Contributor Author

@DmitryKuzmenko Rebased & blackened, all tests are passing!

@dwoz dwoz merged commit 353d20e into saltstack:master Apr 14, 2020
@sagetherage sagetherage added the ZRelease-Sodium retired label label May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ZRelease-Sodium retired label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants