Skip to content
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

Added a cache for skin filenames to improve EPG performance. #2928

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dachaplin
Copy link

@dachaplin dachaplin commented Jun 6, 2023

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.

@jbleyel
Copy link
Contributor

jbleyel commented Jun 6, 2023

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.

@jbleyel jbleyel marked this pull request as draft June 6, 2023 20:58
@dachaplin
Copy link
Author

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.

@jbleyel
Copy link
Contributor

jbleyel commented Jun 6, 2023

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.

@dachaplin
Copy link
Author

Maybe just turn caching on in places like opening the EPG, e.g. setResolveFilenameCaching(true)

@jbleyel
Copy link
Contributor

jbleyel commented Jun 7, 2023

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

@jbleyel
Copy link
Contributor

jbleyel commented Jun 7, 2023

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.

@dachaplin
Copy link
Author

OK. Let me know if you still want the cache dump.

@jbleyel
Copy link
Contributor

jbleyel commented Jun 7, 2023

You can post the dump. This will help us to find the files.

@dachaplin
Copy link
Author

Here's the dump. I opened most of the EPG screens, some settings screens, and a bunch of plugins.

cached-skin-filenames.txt

@kiddac
Copy link

kiddac commented Sep 1, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants