mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make interprocess polling interval configurable (#16560)
As recently there was back-and-forth with this hardcoded value (0.001 -> 0.01 -> 0.005), obviousely the optimal value for it depends on Ansible usage scanario and is better to be configurable. This patch adds a new config option in DEFAULT section, `internal_poll_interval`, with default of 0.001 corresponding to the value hardcoded in Ansible v2.1. This config option is then used instead of hardcoded values where needed. Related GH issue: 14219
This commit is contained in:
parent
f012159860
commit
aa1ec8af17
4 changed files with 20 additions and 3 deletions
|
@ -432,6 +432,20 @@ implications and wish to disable it, you may do so here by setting the value to
|
||||||
|
|
||||||
host_key_checking=True
|
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_file:
|
||||||
|
|
||||||
inventory
|
inventory
|
||||||
|
|
|
@ -146,7 +146,7 @@ DEFAULT_COW_WHITELIST = ['bud-frogs', 'bunny', 'cheese', 'daemon', 'default', 'd
|
||||||
DEFAULTS='defaults'
|
DEFAULTS='defaults'
|
||||||
|
|
||||||
# FIXME: add deprecation warning when these get set
|
# FIXME: add deprecation warning when these get set
|
||||||
#### DEPRECATED VARS ####
|
#### DEPRECATED VARS ####
|
||||||
# use more sanely named 'inventory'
|
# use more sanely named 'inventory'
|
||||||
DEPRECATED_HOST_LIST = get_config(p, DEFAULTS, 'hostfile', 'ANSIBLE_HOSTS', '/etc/ansible/hosts', ispath=True)
|
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
|
# this is not used since 0.5 but people might still have in config
|
||||||
|
@ -195,6 +195,7 @@ DEFAULT_LOG_PATH = get_config(p, DEFAULTS, 'log_path', 'ANSIB
|
||||||
DEFAULT_FORCE_HANDLERS = get_config(p, DEFAULTS, 'force_handlers', 'ANSIBLE_FORCE_HANDLERS', False, boolean=True)
|
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_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_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
|
# static includes
|
||||||
DEFAULT_TASK_INCLUDES_STATIC = get_config(p, DEFAULTS, 'task_includes_static', 'ANSIBLE_TASK_INCLUDES_STATIC', False, boolean=True)
|
DEFAULT_TASK_INCLUDES_STATIC = get_config(p, DEFAULTS, 'task_includes_static', 'ANSIBLE_TASK_INCLUDES_STATIC', False, boolean=True)
|
||||||
|
|
|
@ -26,6 +26,7 @@ from collections import deque
|
||||||
from multiprocessing import Lock
|
from multiprocessing import Lock
|
||||||
from jinja2.exceptions import UndefinedError
|
from jinja2.exceptions import UndefinedError
|
||||||
|
|
||||||
|
from ansible import constants as C
|
||||||
from ansible.compat.six.moves import queue as Queue
|
from ansible.compat.six.moves import queue as Queue
|
||||||
from ansible.compat.six import iteritems, string_types
|
from ansible.compat.six import iteritems, string_types
|
||||||
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable
|
from ansible.errors import AnsibleError, AnsibleParserError, AnsibleUndefinedVariable
|
||||||
|
@ -530,7 +531,7 @@ class StrategyBase:
|
||||||
results = self._process_pending_results(iterator)
|
results = self._process_pending_results(iterator)
|
||||||
ret_results.extend(results)
|
ret_results.extend(results)
|
||||||
if self._pending_results > 0:
|
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")
|
display.debug("no more pending results, returning what we have")
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ __metaclass__ = type
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from ansible import constants as C
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.playbook.included_file import IncludedFile
|
from ansible.playbook.included_file import IncludedFile
|
||||||
from ansible.plugins import action_loader
|
from ansible.plugins import action_loader
|
||||||
|
@ -202,7 +203,7 @@ class StrategyModule(StrategyBase):
|
||||||
display.debug("done adding collected blocks to iterator")
|
display.debug("done adding collected blocks to iterator")
|
||||||
|
|
||||||
# pause briefly so we don't spin lock
|
# pause briefly so we don't spin lock
|
||||||
time.sleep(0.001)
|
time.sleep(C.DEFAULT_INTERNAL_POLL_INTERVAL)
|
||||||
|
|
||||||
# collect all the final results
|
# collect all the final results
|
||||||
results = self._wait_on_pending_results(iterator)
|
results = self._wait_on_pending_results(iterator)
|
||||||
|
|
Loading…
Reference in a new issue