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

[WIP] Start of work to redo the threading and forking split #44280

Closed
wants to merge 18 commits into from

Conversation

jimi-c
Copy link
Member

@jimi-c jimi-c commented Aug 16, 2018

This refactors the way we handle process management by introducing the ProcessModel* classes. Right now, these will remain hard-coded as there's no real plans to add others in the future beyond threading/forking.

As a WIP, this PR enables threading by default, however when merged forking will be the default as it is today. Threading will have to be enabled via a config change (environment variable or ansible.cfg).

@jimi-c
Copy link
Member Author

jimi-c commented Aug 16, 2018

!jimi_skip

@sivel sivel self-requested a review August 16, 2018 20:06
lib/ansible/executor/process/threading.py Outdated Show resolved Hide resolved
lib/ansible/executor/process/threading.py Outdated Show resolved Hide resolved
@jimi-c jimi-c force-pushed the threading_and_forking_redux branch 6 times, most recently from 14250bc to 9fb6066 Compare August 21, 2018 13:51
lib/ansible/config/base.yml Outdated Show resolved Hide resolved
lib/ansible/executor/process/forking.py Outdated Show resolved Hide resolved
lib/ansible/executor/process/forking.py Outdated Show resolved Hide resolved
@sivel
Copy link
Member

sivel commented Aug 21, 2018

A general comment, Ctrl-c doesn't seem to work with threading. I cannot abort the playbook run.

@jimi-c jimi-c force-pushed the threading_and_forking_redux branch 3 times, most recently from 64e3454 to 6ef1796 Compare August 24, 2018 17:22
@mattclay mattclay added the ci_verified Changes made in this PR are causing tests to fail. label Sep 4, 2018
@jimi-c jimi-c force-pushed the threading_and_forking_redux branch from 6ef1796 to a76a01b Compare November 9, 2018 21:04
@dw
Copy link
Contributor

dw commented Nov 26, 2018

Is there any chance of the plugins/loader.py patches landing for 2.8? They are fairly low impact, and useful elsewhere regardless of the remaining refactor

Also I'm worried #45572 may need reverted (or locks added) with respect to this PR, it shares the Templar across threads:

It does not seem possible for concurrent calls into one (non-copied) VariableManager instance, and so it need not be reentrant.

@jimi-c jimi-c force-pushed the threading_and_forking_redux branch 3 times, most recently from 593a756 to 1e4b019 Compare December 14, 2018 06:14
__all__ = ["ProcessModelBase", "keyboard_interrupt_event", "ResultsSentinel"]


class ResultsSentinel:
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, we have a sentinel available in ansible.utils.sentinel now. Not sure if it's worth using that instead.

__all__ = ['ProcessModel',]


class ProcessModel(ProcessModelBase):
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it would be useful for something later, but should we have a class attr with the name of the plugin in it? Some plugin types do this others don't.

Copy link
Member

Choose a reason for hiding this comment

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

_load_name gets appended by loader itself

@jimi-c jimi-c force-pushed the threading_and_forking_redux branch 3 times, most recently from f20c494 to 941d32e Compare June 21, 2019 15:11
jimi-c and others added 17 commits June 21, 2019 10:18
* Also reverts the default model back to forking
This was in the original TQM use to protect against the possibility
that /dev/shm was not available.
* Also fixes a bug in which the callback for tasks being started in
  threads was when the task data was put on the queue, not when it was
  popped by a worker and actually started.
A longer term solution should move the decision to run with
threading or forking into the tests themselves, instead of being
dependent on the configuration of the test environment.

ci_complete
This reverts commit 4c66fa35cfa562480dbc223e0fa22be9e01f043d.
@jimi-c jimi-c force-pushed the threading_and_forking_redux branch from 941d32e to f5c6c1c Compare June 21, 2019 15:21
@emousse
Copy link

emousse commented Apr 3, 2020

Hi!
Can you please tell me if you are still working on this branch ?

@jimi-c
Copy link
Member Author

jimi-c commented Jun 1, 2020

@emousse not really. A few things popped up regarding non-thread-safe methods we use in python, and I cannot confidently say those will ever be addressed. As such I've turned my attention to alternative ways of improving the performance of the core engine. I'm going to go ahead and close this WIP now as it's quite out of date.

@jimi-c jimi-c closed this Jun 1, 2020
@jimi-c jimi-c deleted the threading_and_forking_redux branch June 1, 2020 14:43
@ansible ansible locked and limited conversation to collaborators Jun 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ci_verified Changes made in this PR are causing tests to fail.
Projects
No open projects
Ansible 2.9
TODO: Backlog, anything can go here. ...
Development

Successfully merging this pull request may close these issues.

None yet

7 participants