-
Notifications
You must be signed in to change notification settings - Fork 23.8k
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
Ansible tasks slow down as host facts grow #73654
Comments
Files identified in the description: If these files are incorrect, please update the |
This is most likely due to Another thing that could help is changing the stage at which variables are evaluated for the |
Looks like the plugin stage configuration per https://docs.ansible.com/ansible/latest/plugins/vars.html#using-vars-plugins is:
This didn't seem to improve anything.
|
That's good that disabling fact inject made a difference. Ultimately, I'm not sure there is much we can do without significantly rewriting how we process the data. More data takes more time to process, and we process it a lot. I am working on some things for the 2.11 release right now. I will dig into this again once that work is complete. |
Sure. Ping me when you have time and I can share what I've found. Package facts brings the fact size (at least in cache) up from 5.5k to ~313k so we're dealing with 1.6M vs 58M of facts. Network facts for ended up being like 123M |
See ansible/ansible#73654 Change-Id: Ib7e1fa820767fe419eadd6309311204433e9bf20
* Update openstack-ansible-apt_package_pinning from branch 'master' to 7c8888ac6de9e0be549270247e849a6c09031158 - Use ansible_facts[] instead of fact variables See ansible/ansible#73654 Change-Id: Ib7e1fa820767fe419eadd6309311204433e9bf20
See ansible/ansible#73654 Change-Id: Id98f052df73587f209b9621da0874ce506899f9b
* Update openstack-ansible-haproxy_server from branch 'master' to d78f6d55282e52be919209bd18220eea1a41a2f7 - Use ansible_facts[] instead of fact variables See ansible/ansible#73654 Change-Id: Id98f052df73587f209b9621da0874ce506899f9b
See ansible/ansible#73654 Change-Id: I5a83a7f237e4b7d86e8d7ee08b0e8c6b4f8a44f8
* Update ansible-role-systemd_mount from branch 'master' to e5cc6f8990e82b92bc489c701f849120ec23f2fa - Use ansible_facts[] instead of fact variables See ansible/ansible#73654 Change-Id: I5a83a7f237e4b7d86e8d7ee08b0e8c6b4f8a44f8
Small update, I've run some more tests and it could be pointed that facts content (keys and values) wrapping into ansible/lib/ansible/utils/unsafe_proxy.py Lines 135 to 136 in eb72c36
|
* Update openstack-ansible-lxc_container_create from branch 'master' to 5d22a389c257f189a6a8ab42973e8c142df08169 - Use ansible_facts[] instead of fact variables See ansible/ansible#73654 Change-Id: If6b30e40bf71f60ee72fdc1459ce5e5a9f4f7d93
See ansible/ansible#73654 Change-Id: If6b30e40bf71f60ee72fdc1459ce5e5a9f4f7d93
* Update ansible-role-uwsgi from branch 'master' to 15f24d11f34bfab6c4170de5b1b2c65363794dc5 - Use ansible_facts[] instead of fact variables See ansible/ansible#73654 Change-Id: Ibadca3bdce6d7adf51ddce9591a0d404e38d5e71
See ansible/ansible#73654 Change-Id: Ibadca3bdce6d7adf51ddce9591a0d404e38d5e71
See ansible/ansible#73654 Change-Id: Ia6dac13c7e2206f4a86ef8e21c5b1cd80eb16e0e
* Update openstack-ansible-rabbitmq_server from branch 'master' to b8fc8721133157d958344147a7d99f0f6cc8e559 - Use ansible_facts[] instead of fact variables See ansible/ansible#73654 Change-Id: Ia6dac13c7e2206f4a86ef8e21c5b1cd80eb16e0e
See ansible/ansible#73654 Change-Id: I8c5d46a9d612b6800b6dde37a324e2357cf99217
I have been moved to another team and will unfortunately not be able to look into this. 😞 |
* Update openstack-ansible-os_murano from branch 'master' to 365c00be6a6dfc96a5fe8d5d7485a638063288e7 - Merge "Use ansible_facts[] instead of fact variables" - Use ansible_facts[] instead of fact variables See ansible/ansible#73654 Change-Id: Icea956af90672dae1d50e84f727b2772fd35e26f
See ansible/ansible#73654 Change-Id: Icea956af90672dae1d50e84f727b2772fd35e26f
Hopefully not too off topic, but I’ve been on a recent kick to optimize some plays and workflows I have, and as hostvars increase I do see a correlation to runtimes increase especially when run against large host inventories. I’m going to test this, but if I use This should not be too far off topic given I’m trying to workaround the same root cause of slowdowns. I was just not clear if |
|
If you were using In the end 'clear all facts' would clear 'all hostvars' for your case, which might be a lot more than intended (once set_fact sets a hostvar there is no distinction). |
Good insight @bcoca . Thanks |
This comment was marked as off-topic.
This comment was marked as off-topic.
I found what that silent var crunching is. Ansible silently processes vars for tasks that will not run due to not being matched by |
since 'tags' can be dynamic (set to a variable) ... we don't know until they are processed and templated, it could be different it tags were 'static' |
I noticed that in my setup( |
This comment was marked as off-topic.
This comment was marked as off-topic.
@Vladimir-csp you are basically asking for us to code 2 diff parsing engines and use them on a toggle, also that would require opening a specific ticket (if not a proposal, since this is far from trivial) |
to prepare for turning off inject_facts_as_vars in order to speed up ansible. for reasoning see ansible/ansible#73654
to prepare for turning off inject_facts_as_vars in order to speed up ansible. for reasoning see ansible/ansible#73654
to prepare for turning off inject_facts_as_vars in order to speed up ansible. for reasoning see ansible/ansible#73654
to prepare for turning off inject_facts_as_vars in order to speed up ansible. for reasoning see ansible/ansible#73654
to prepare for turning off inject_facts_as_vars in order to speed up ansible. for reasoning see ansible/ansible#73654
to prepare for turning off inject_facts_as_vars in order to speed up ansible. for reasoning see ansible/ansible#73654
to prepare for turning off inject_facts_as_vars in order to speed up ansible. for reasoning see ansible/ansible#73654
to prepare for turning off inject_facts_as_vars in order to speed up ansible. for reasoning see ansible/ansible#73654
See ansible/ansible#73654 Change-Id: Ia3c80d5c0e63ee9c38868c41c9235c51a2498971
waiting on data tagging |
SUMMARY
As the size of host facts is increased, there is a serious slow down in the number of tasks that can be processed per second. This can be viewed at smaller scale, but is dramatic at ~150 nodes. This can happen because of network facts (with many interfaces 100+), service facts, or package facts. This can also be easily reproduced with loading a large static fact structure (>100KB) and filtering to ansible_local.
I was able to pin point one of the issues coming from the get_vars in the host task processing:
https://github.com/ansible/ansible/blob/stable-2.9/lib/ansible/plugins/strategy/linear.py#L282-L283
This was seen to take <10ms with no facts and ~200ms with facts. Since host task processing is performed serially, the result is that <= 5 tasks can be processed per second at this scale.
There is another issue with the amount of memory and the workers being spawned, but the task execution slowdown seems to be more consistent.
ISSUE TYPE
COMPONENT NAME
lib/ansible/vars/manager.py
lib/ansible/plugins/strategy/linear.py
ANSIBLE VERSION
ansible-2.9.17-1.el8ae.noarch
CONFIGURATION
OS / ENVIRONMENT
RHEL8.2
This has been seen on OpenStack compute nodes with an average of 200 network interfaces. This same effect can be reproduced without network facts and using service facts or package facts.
STEPS TO REPRODUCE
EXPECTED RESULTS
Task execution should not slow down when the number of Ansible host facts increase.
ACTUAL RESULTS
Execution against 179 hosts
The text was updated successfully, but these errors were encountered: