# Major ansible-core cache performance regression since 2.19 - Where to share real world profiling data?

**URL:** <https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263>\
**Category:** Get Help\
**Created:** [September 4, 2026, 2:18pm UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263 "2026-09-04T14:18:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![olavrb](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/olavrb/32/10223_2.png) [@olavrb](https://forum.ansible.com/u/olavrb)\
**Post date:** [September 4, 2026, 2:18pm UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/1 "2026-09-04T14:18:31Z")

</div>

Ever since `ansible-core` v2.19 we’ve seen a major (\>10x) performance regression in using inventory cache.

There is this existing issue on GitHub:

- 2025-12-03: [https://github.com/ansible/ansible/issues/86292](https://github.com/ansible/ansible/issues/86292)

I have used cPython to profile real world usage of 2.18.19 (fast) vs. 2.21.3 (slow), but I’d like to not share that info publicly in case it contains data that should not be shared publicly.

@shertel: How can I share this data with you or all the contributors in a non-public way?

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [September 9, 2026, 12:29am UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/2 "2026-09-09T00:29:43Z")

</div>

Good news, I don’t think more data is necessary. Profiling data is what I used as the basis for my current draft, which wasn’t great since the cause wasn’t apparent from profiling data.

I’m exploring possible options and need to discuss more with [@Core](https://forum.ansible.com/groups/core), but the 3rd LLM-generated reproducer [you most recently shared](https://github.com/ansible/ansible/pull/86551#issuecomment-5526415503) contains a comment about the probable cause, which is [ansible\_modules/plugins/inventory/nb\_inventory.py at e8ec5859095b6bfd79a230fba30f9029f7999adf · netbox-community/ansible\_modules · GitHub](https://github.com/netbox-community/ansible_modules/blob/e8ec5859095b6bfd79a230fba30f9029f7999adf/plugins/inventory/nb_inventory.py#L490). This explains why the performance issue is only affecting users of that inventory plugin, since using the self.loader object to load random JSON payloads (instead of the `json` lib) is not recommended.

I’ll update my draft when I can. Thanks for your effort in helping me reproduce the issue!

---

<div class="post-metadata">

**Author:** ![olavrb](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/olavrb/32/10223_2.png) [@olavrb](https://forum.ansible.com/u/olavrb)\
**Post date:** [September 17, 2026, 2:40pm UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/3 "2026-09-17T14:40:20Z")

</div>

How are the discussions going?

Should be fast to test, if I understand correctly there is just one change from `self.loader.load()` to `json.loads()` on that line?

Edit: Made a draft PR here [https://github.com/netbox-community/ansible\_modules/pull/1602](https://github.com/netbox-community/ansible_modules/pull/1602), will test it once I’m back to work next week.

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [September 17, 2026, 3:31pm UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/4 "2026-09-17T15:31:11Z")

</div>

Yeah, seems like the plugin should probably be using `json.loads()`. I have no idea why it’s using `self.loader.load` there.

In terms of ansible-core, I am still investigating solutions and don’t have an update. Once I identify possible options I will discuss which the team prefers and update my draft. But anyone is welcome to take a stab at improving it, it doesn’t need to wait on me.

It’s not clear to me if your reproducer is the same as [performance regression when reading from inventory cache · Issue #86292 · ansible/ansible · GitHub](https://github.com/ansible/ansible/issues/86292), because you said [jsonfile: add option to configure the cache format by s-hertel · Pull Request #87479 · ansible/ansible · GitHub](https://github.com/ansible/ansible/pull/87479#issuecomment-5537107630) didn’t help with the issue, but that toggle would work around this specific issue for the `jsonfile` cache plugin since it discards the tags from `self.loader.load` instead of caching them.

---

<div class="post-metadata">

**Author:** ![olavrb](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/olavrb/32/10223_2.png) [@olavrb](https://forum.ansible.com/u/olavrb)\
**Post date:** [September 24, 2026, 7:07am UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/5 "2026-09-24T07:07:24Z")

</div>

Using `json.loads()` made no improvement on cache read and parse performance. Looks like that code path is about reading HTTP response, not cache?

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [September 24, 2026, 4:08pm UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/6 "2026-09-24T16:08:50Z")

</div>

Hm, I see a large performance difference. When testing, I delete the cache, populate it, then run the command a second time to see how long it takes to read the cache. This [reproducer](https://gist.github.com/s-hertel/e8548a366b44625ebda6ea50f778a590) isolating the cache behavior takes about a minute to read from the cache due to setting the cache with tagged data from self.loader. If I update it to not set the cache using tagged data from self.loader, reading from the cache takes \<1 second.

---

<div class="post-metadata">

**Author:** ![olavrb](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/olavrb/32/10223_2.png) [@olavrb](https://forum.ansible.com/u/olavrb)\
**Post date:** [September 28, 2026, 12:14pm UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/7 "2026-09-28T12:14:08Z")

</div>

I tested again now, making sure the cache is created with that change too.

Wow. The difference is huge. 6s vs 7m7s.

I reopened the PR and added my timings to it:

[https://github.com/netbox-community/ansible\_modules/pull/1602#issuecomment-5797002533](https://github.com/netbox-community/ansible_modules/pull/1602#issuecomment-5797002533)

---

<div class="post-metadata">

**Author:** ![olavrb](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/olavrb/32/10223_2.png) [@olavrb](https://forum.ansible.com/u/olavrb)\
**Post date:** [October 5, 2026, 12:05pm UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/8 "2026-10-05T12:05:01Z")

</div>

What should be suggested as a fix then, ref. your finding ( [https://github.com/netbox-community/ansible\_modules/pull/1602#issuecomment-5936279569](https://github.com/netbox-community/ansible_modules/pull/1602#issuecomment-5936279569) → [https://github.com/netbox-community/ansible\_modules/pull/1114](https://github.com/netbox-community/ansible_modules/pull/1114) ) saying `self.loader.load()` is intentional?

---

<div class="post-metadata">

**Author:** ![shertel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/shertel/32/1241_2.png) [@shertel](https://forum.ansible.com/u/shertel)\
**Post date:** [October 5, 2026, 1:33pm UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/9 "2026-10-05T13:33:23Z")

</div>

Have you had a discussion with the maintainers? I don’t even know how the feature works, so I can’t suggest a fix.

---

<div class="post-metadata">

**Author:** ![olavrb](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/olavrb/32/10223_2.png) [@olavrb](https://forum.ansible.com/u/olavrb)\
**Post date:** [October 7, 2026, 10:48am UTC](https://forum.ansible.com/t/major-ansible-core-cache-performance-regression-since-2-19-where-to-share-real-world-profiling-data/46263/10 "2026-10-07T10:48:37Z")

</div>

Maintainers haven’t interacted with the PR yet, so no. I’ll try to `@` some of them in the PR.
