Added a cache for skin filenames to improve EPG performance.
I've been profiling opening the graphical EPG in MetrixHD (on a Zgemma H.2S) and noticed that a lot of time is spent in resolveFilename():
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 1.776 1.776 /usr/lib/enigma2/python/Screens/InfoBarGenerics.py:2021(openGraphEPG)
...
75 0.080 0.001 0.432 0.006 /usr/lib/enigma2/python/Tools/Directories.py:90(resolveFilename)
It is taking 0.432 seconds just to resolve filenames. With more rows in the EPG and using other skins this can go even higher (it was over 0.5 seconds for me, using Slyk Onyx with 16 rows).
I tried adding a cache of resolved filenames and this reduced the time considerably, especially once the cache is created after the first call to openGraphEPG():
75 0.049 0.001 0.214 0.003 /usr/lib/enigma2/python/Tools/Directories.py:91(resolveFilename)
75 0.007 0.000 0.008 0.000 /usr/lib/enigma2/python/Tools/Directories.py:91(resolveFilename)
75 0.007 0.000 0.008 0.000 /usr/lib/enigma2/python/Tools/Directories.py:91(resolveFilename)
75 0.006 0.000 0.007 0.000 /usr/lib/enigma2/python/Tools/Directories.py:91(resolveFilename)
I'm new to the Enigma code so I'm not sure if this will cause problems elsewhere, but hopefully something like this can be done.
resolveFilename is used all over the place and not only in graphical EPG. This means you will cache all images and that's not acceptable.
If you wanna have cache the you should cache the image itself in graphical EPG and not the filename.
I restricted it to SCOPE_GUISKIN so it only caches the filenames of skin files. Skin files don't move around, do they?
Taking 0.4-0.5 seconds just to find these files seems ridiculous.
You probably miss one thing. We also support other skins like Metrix and resolveFilename is also for fallback if the image is not in the main skin. As I said .. You really wanna cache ALL image file names in all screens? For Metrix : we talk about round about 1560 files + all files from default skin which are not in Metrix.
This may kill low memory boxes.
Maybe just turn caching on in places like opening the EPG, e.g. setResolveFilenameCaching(true)
Can you please run your box for a while and open a lot of screens and plugins and then dump the content of your cache in the log or extra file. You should call the dump in StartEnigma after that line
https://github.com/openatv/enigma2/blob/master/lib/python/StartEnigma.py#L938
Restart GUI will then call the dump
Hi @dachaplin, we will do that differently by adding the cache into EPG. Your finding is correct but your suggestion can be more optimized by caching the images itself and not only the names. This improvement is already in our pipeline. So please be patient.
OK. Let me know if you still want the cache dump.
You can post the dump. This will help us to find the files.
Here's the dump. I opened most of the EPG screens, some settings screens, and a bunch of plugins.
There is probably no way of knowing if a skin or plugin is programmatically changing the same image. Caching images will cause problems for any skin or plugin that use the same named graphic file for picons, posters, backdrops or any other changed graphic. Don't do this.