Media cache performance impact on all files

My Asterisk servers make heavy use of media caching. As the cache grows, performance of common Read and Playback operations for local files is impacted.

To be clear, I’m referring to when I’m doing a Playback command of a local file like this:
exten => s,n,Playback(thankyou)

Even those operations are searching the media cache. As the cache size grows, the performance of that type of call is impacted. I’m noticing a multi-second delay from the time the Playback command is executed to when the caller hears the audio.

The delay grows significantly over time as the cache grows bigger.

I’ve seen upwards of a 30-second delay when there are thousands of cache files and the server is under heavy load. The amount of delay varies depending on load and horsepower of the server.

After searching through the source code, it appears that all file exist operations attempt to first locate the file in the media cache - regardless of whether it’s a remote file or not.

I’m specifically looking at fileexists_test() function in main/file.c - the very first thing it does is search through ast_media_cache_retrieve().

Any guidance on how to deal with this?

I’m running Asterisk 15.4.1.

I’ve submitted an issue for this behavior.
https://issues.asterisk.org/jira/browse/ASTERISK-28625