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 interprocess polling interval configurable #16560

Merged
merged 1 commit into from
Oct 6, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions docsite/rst/intro_configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,20 @@ implications and wish to disable it, you may do so here by setting the value to

host_key_checking=True

.. _internal_poll_interval:

internal_poll_interval
======================

.. versionadded:: 2.2

This sets the interval (in seconds) of Ansible internal processes polling each other.
Lower values improve performance with large playbooks at the expense of extra CPU load.
Higher values are more suitable for Ansible usage in automation scenarios, when UI responsiveness is not required but CPU usage might be a concern.
Default corresponds to the value hardcoded in Ansible ≤ 2.1::

internal_poll_interval=0.001

.. _inventory_file:

inventory
Expand Down
3 changes: 2 additions & 1 deletion lib/ansible/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def load_config_file():
DEFAULTS='defaults'

# FIXME: add deprecation warning when these get set
#### DEPRECATED VARS ####
#### DEPRECATED VARS ####
# use more sanely named 'inventory'
DEPRECATED_HOST_LIST = get_config(p, DEFAULTS, 'hostfile', 'ANSIBLE_HOSTS', '/etc/ansible/hosts', ispath=True)
# this is not used since 0.5 but people might still have in config
Expand Down Expand Up @@ -195,6 +195,7 @@ def load_config_file():
DEFAULT_FORCE_HANDLERS = get_config(p, DEFAULTS, 'force_handlers', 'ANSIBLE_FORCE_HANDLERS', False, boolean=True)
DEFAULT_INVENTORY_IGNORE = get_config(p, DEFAULTS, 'inventory_ignore_extensions', 'ANSIBLE_INVENTORY_IGNORE', ["~", ".orig", ".bak", ".ini", ".cfg", ".retry", ".pyc", ".pyo"], islist=True)
DEFAULT_VAR_COMPRESSION_LEVEL = get_config(p, DEFAULTS, 'var_compression_level', 'ANSIBLE_VAR_COMPRESSION_LEVEL', 0, integer=True)
DEFAULT_INTERNAL_POLL_INTERVAL = get_config(p, DEFAULTS, 'internal_poll_interval', None, 0.001, floating=True)

# static includes
DEFAULT_TASK_INCLUDES_STATIC = get_config(p, DEFAULTS, 'task_includes_static', 'ANSIBLE_TASK_INCLUDES_STATIC', False, boolean=True)
Expand Down
3 changes: 2 additions & 1 deletion lib/ansible/plugins/strategy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from multiprocessing import Lock
from jinja2.exceptions import UndefinedError

from ansible import constants as C
from ansible.compat.six.moves import queue as Queue
from ansible.compat.six import iteritems, string_types
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable
Expand Down Expand Up @@ -530,7 +531,7 @@ def _wait_on_pending_results(self, iterator):
results = self._process_pending_results(iterator)
ret_results.extend(results)
if self._pending_results > 0:
time.sleep(0.001)
time.sleep(C.DEFAULT_INTERNAL_POLL_INTERVAL)

display.debug("no more pending results, returning what we have")

Expand Down
3 changes: 2 additions & 1 deletion lib/ansible/plugins/strategy/free.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import time

from ansible import constants as C
from ansible.errors import AnsibleError
from ansible.playbook.included_file import IncludedFile
from ansible.plugins import action_loader
Expand Down Expand Up @@ -202,7 +203,7 @@ def run(self, iterator, play_context):
display.debug("done adding collected blocks to iterator")

# pause briefly so we don't spin lock
time.sleep(0.001)
time.sleep(C.DEFAULT_INTERNAL_POLL_INTERVAL)

# collect all the final results
results = self._wait_on_pending_results(iterator)
Expand Down