# Jinja2 2.9 performance degradation

**URL:** <https://forum.ansible.com/t/jinja2-2-9-performance-degradation/35024>\
**Category:** Ansible Project\
**Created:** [April 21, 2021, 1:24pm UTC](https://forum.ansible.com/t/jinja2-2-9-performance-degradation/35024 "2021-04-21T13:24:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick\_Hemmer](https://avatars.discourse-cdn.com/v4/letter/p/47e85d/32.png) [@Patrick\_Hemmer](https://forum.ansible.com/u/Patrick_Hemmer)\
**Post date:** [April 21, 2021, 1:24pm UTC](https://forum.ansible.com/t/jinja2-2-9-performance-degradation/35024/1 "2021-04-21T13:24:11Z")

</div>

So I was trying to upgrade an older Ansible environment from Ansible 2.7 + Jinja2 2.8 and ran across some severe performance degradation. A template task that used to take about 30 sec to complete across all hosts now takes about 15 min, bottlenecking on the CPU of the management host.

I ran across [https://github.com/ansible/ansible/issues/68763](https://github.com/ansible/ansible/issues/68763) which was part of the issue. However even restricting Ansible to version 2.9.5 we hit another performance issue going from Jinja2 2.8 → 2.9. After bisecting the Jinja2 commits, the culprit is [https://github.com/pallets/jinja/commit/d67f0fd4cc2a4af08f51f4466150d49da7798729](https://github.com/pallets/jinja/commit/d67f0fd4cc2a4af08f51f4466150d49da7798729)

Unfortunately I don’t know enough about the Ansible internals and its integration with Jinja2 to understand what’s going on here. Can someone explain why this change would cause such a severe performance impact?
